spring-data-jpa

Writing CRUDRepository's findBy() method on a field annotated by JoinColumn

风流意气都作罢 提交于 2020-08-24 06:00:44
问题 I'm kind of new to Spring JPA, so I apologize in advance if my question sounds basic. I have 2 entity objects: OrderInfo, and PersonInfo. The classes are as below: @Entity @Table(name="order_info") @NamedQuery(name="OrderInfo.findAll", query="SELECT o FROM OrderInfo o") public class OrderInfo implements Serializable { @Column(name="order_number") private String orderNumber; //bi-directional many-to-one association to PersonInfo @ManyToOne @JoinColumn(name="person_id") private PersonInfo

@NotNull : validation custom message not displaying

十年热恋 提交于 2020-08-24 03:33:23
问题 I am using spring data JPA for creating application. In that I am trying to implement server side validation using annotation. I added @NotNull annotation on filed with custom message. I also added @valid with @RequestBody But problem is that when I am passing nAccountId as null I am not getting custom message i.e. Account id can not be null I am getting "message": "Validation failed for object='accountMaintenanceSave'. Error count: 1", . Can any one please tell me why I am not getting custom

@NotNull : validation custom message not displaying

时光毁灭记忆、已成空白 提交于 2020-08-24 03:31:48
问题 I am using spring data JPA for creating application. In that I am trying to implement server side validation using annotation. I added @NotNull annotation on filed with custom message. I also added @valid with @RequestBody But problem is that when I am passing nAccountId as null I am not getting custom message i.e. Account id can not be null I am getting "message": "Validation failed for object='accountMaintenanceSave'. Error count: 1", . Can any one please tell me why I am not getting custom

TransactionRequiredException: no transaction is in progress while using JPAItemWriter

∥☆過路亽.° 提交于 2020-08-22 12:03:53
问题 I am facing weird issue with an application which is a spring boot application. Details Here: The app has a spring batch job which uses JpaItemWriter for performing the writes to the database. Also, the application is configured to use hibernate ItemWriter configuration as follows: @Bean(name = "itemWriter") @StepScope public ItemWriter<Record> itemWriter() { JpaItemWriter<Record> itemWriter = new JpaItemWriter<>(); itemWriter.setEntityManagerFactory(emf); return itemWriter; } The batch job

Spring Boot JPA saveAll() inserting to database extremely slowly

二次信任 提交于 2020-08-10 22:13:28
问题 I am using Spring Boot in conjunction with Hibernate to create the RESTful API for a simple web app where I read a .csv file and insert each row into a mysql database table. I am able to successfully do this but it's taking a very long time for any large csv file. I understand that it's better to batch my insert statements to reduce number of transactions but I don't think I am making that happen with the current code I have. This is what I currently am doing (which works but very slowly):

Jpa Repository save() doesn't update existing data

旧城冷巷雨未停 提交于 2020-08-10 22:08:11
问题 I am trying to update data and as I know save() method saves entity if the id is null or update an existing entity in the database if the given id is found in DB. However, when I try to save data it is not updated: public Employer update() { Employer emp = Employer.builder() .id(2L) // it exists in database .name('new company name') .build(); return repository.save(emp); } But, when I retrieve data from the database and update its fields and save again it updates: public Employer update() {

Caused by: java.lang.IllegalArgumentException: Property 'driverClassName' must not be empty

陌路散爱 提交于 2020-08-10 19:27:26
问题 In the code I have shared here Exception in thread "restartedMain" java.lang.reflect.InvocationTargetException Caused by: java.lang.NullPointerException I am getting new error. Could you please help me with this. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springLogging3Application': Unsatisfied dependency expressed through field 'factory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating

Stack overflow error for hibernate one-to-one mapping with Spring Data JPA

有些话、适合烂在心里 提交于 2020-08-10 19:22:16
问题 My problem is similar to this one https://discourse.hibernate.org/t/hibernate-throws-org-hibernate-id-identifiergenerationexception-attempted-to-assign-id-from-null-one-to-one-property/1777 but I am getting a different exception after applying the answer from this thread. My entities: @Entity @Table(name = "location") public class Location { @Id private Long id; @Column(name = "country_code") private String countryCode; private Double longitude; private Double latitude; @OneToOne(fetch =

Stack overflow error for hibernate one-to-one mapping with Spring Data JPA

吃可爱长大的小学妹 提交于 2020-08-10 19:21:35
问题 My problem is similar to this one https://discourse.hibernate.org/t/hibernate-throws-org-hibernate-id-identifiergenerationexception-attempted-to-assign-id-from-null-one-to-one-property/1777 but I am getting a different exception after applying the answer from this thread. My entities: @Entity @Table(name = "location") public class Location { @Id private Long id; @Column(name = "country_code") private String countryCode; private Double longitude; private Double latitude; @OneToOne(fetch =

Stack overflow error for hibernate one-to-one mapping with Spring Data JPA

拜拜、爱过 提交于 2020-08-10 19:20:14
问题 My problem is similar to this one https://discourse.hibernate.org/t/hibernate-throws-org-hibernate-id-identifiergenerationexception-attempted-to-assign-id-from-null-one-to-one-property/1777 but I am getting a different exception after applying the answer from this thread. My entities: @Entity @Table(name = "location") public class Location { @Id private Long id; @Column(name = "country_code") private String countryCode; private Double longitude; private Double latitude; @OneToOne(fetch =