spring-data-jpa


Spring Boot with MySQL is shutting down immedietly

给你一囗甜甜゛ 提交于 2020-01-25 09:33:44
问题 My first Spring Boot application with MySQL and JPA is shutting down immediately and I do not have any clue on the reasons. 2018-08-15 16:24:42.050 INFO 10960 --- [ restartedMain] com.classpath.SampleAppApplication : Starting SampleAppApplication on LAPTOP-MAI0FJBD with PID 10960 (C:\Users\classpath\projects\sample-app\target\classes started by classpath in C:\Users\classpath\projects\sample-app) 2018-08-15 16:24:42.065 INFO 10960 --- [ restartedMain] com.classpath.SampleAppApplication : No

Why aspect not triggered for owner side in OneToOne relationship?

泄露秘密 提交于 2020-01-25 08:42:29
问题 For example, I have a bidirectional one-to-one relationship: public class Document { @OneToOne(mappedBy = "document", cascade = CascadeType.ALL) private DocumentMetadata documentMetadata; } public class DocumentMetadata { @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "document_id") private Document document; } When I save the Document entity by using Spring Data, it also saves the DocumentMetadata entity: DocumentMetadata documentMetadata = DocumentMetadata.builder() /*some fields are

Hibernate is making extra SQL statement with @ManyToOne and @Lazy fetching object

我的未来我决定 提交于 2020-01-25 07:58:43
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. Sahbaz wants to draw more attention to this question. I would like someone to explain me why Hibernate is making one extra SQL statement in my straight forward case. Basically i have this object: @Entity class ConfigurationTechLog ( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long?, val configurationId: Long, val type: String, val value: String? ) { @JsonIgnore @ManyToOne

Spring JPA - Multiply nested tables applying WHERE clause

本小妞迷上赌 提交于 2020-01-25 07:53:22
问题 I already created question before which was complicated. So I am creating a new one which will be as simple as possible. I am having a problem with Spring JPA especially twice nested structure. Here is a super simple relationship diagram: The country has multiple rivers and rivers can flow through multiple countries. The river has multiple bridges but the bridge can be built over 1 river only. So M:N -> 1:N This is the expected result: { countries: [ { countryID: 1, rivers: [ { riverID: 1,

org.hibernate.id.IdentifierGenerationException: “attempted to assign id from null one-to-one property”

青春壹個敷衍的年華 提交于 2020-01-25 07:24:13
问题 I have a problem when i try to save the user object to database using Spring Boot 2.1.6.RELEASE and Spring Data JPA. user object and detail object have a bidirectional one-to-one relation. The id of detail have a foreign key to id of user(the id of user is autoincrement). user information is map from json format to a object with @RequestBody. json: {"name" : "Jhon", "detail": { "city" : "NY" } } userController.java: ... @PostMapping(value="/user") public Boolean agregarSolicitiud(@RequestBody

org.hibernate.id.IdentifierGenerationException: “attempted to assign id from null one-to-one property”

自古美人都是妖i 提交于 2020-01-25 07:24:07
问题 I have a problem when i try to save the user object to database using Spring Boot 2.1.6.RELEASE and Spring Data JPA. user object and detail object have a bidirectional one-to-one relation. The id of detail have a foreign key to id of user(the id of user is autoincrement). user information is map from json format to a object with @RequestBody. json: {"name" : "Jhon", "detail": { "city" : "NY" } } userController.java: ... @PostMapping(value="/user") public Boolean agregarSolicitiud(@RequestBody

Postgresl select count(*) time-consuming

自古美人都是妖i 提交于 2020-01-25 04:41:07
问题 I am using spring-data-jpa & postgresql-9.4 . There is a table: tbl_oplog . This table has about seven million rows of data, and data is need to be displayed on the front end.(paged). I use Spring#PagingAndSortingRepository , and then I found that the data query was very slow. From the logs, I found that two SQL queries were issued: select oplog0_.id as id1_8_, oplog0_.deleted as deleted2_8_, oplog0_.result_desc as result_d3_8_, oplog0_.extra as extra4_8_, oplog0_.info as info5_8_, oplog0_

SpringDataJpa: Multiple ContainingIgnoreCase

落爺英雄遲暮 提交于 2020-01-25 00:35:07
问题 I have something like below. basically I want to get all the books contains certain keywords in their title or description. Spring keep giving me error on this method. Single select of either Title or Descr works, but I am just not able to put them together. What am I missing? works: findBookByTitleContainingIgnoreCase(String keyWord) findBookByDescrContainingIgnoreCase(String keyWord) doesn't work: findBookByTitleContainingIgnoreCaseOrDescrContainingIgnoreCase(String keyWord) 回答1: This will

Foreign key is always null in one to many relation - Spring Boot Data with JPA

99封情书 提交于 2020-01-24 21:30:08
问题 I have two entity classes Country and Language having bi-directional one to many relationship. Below are the entity classes: @Entity @Table(name = "COUNTRY") public class Country { @Id @GeneratedValue @Column(name = "COUNTRY_ID") private Long id; @Column(name = "COUNTRY_NAME") private String name; @Column(name = "COUNTRY_CODE") private String code; @JacksonXmlElementWrapper(localName = "languages") @JacksonXmlProperty(localName = "languages") @OneToMany(mappedBy = "country", fetch = FetchType

Handling entities inheritance spring boot

匆匆过客 提交于 2020-01-24 21:10:30
问题 I'm working with this tutorial to handle entities inheritance. I have person and company entities that extends the User entity. @Entity @Inheritance public abstract class User { @Id private long id; @NotNull private String email; // getters and settres } @Entity public class Person extends User { private int age; // getters and settres and other attributs } @Entity public class Company extends User { private String companyName; // getters and settres and other attribut } then UserRpository

工具导航Map