Hi fellow software developers, Let’s assume we have the following scenario: we have a system where drivers can register. Each time a new Driver registers, the system automatically builds and assigns a Car to the driver. Let’s consider we have the following rest controller which exposes an endpoint…
Tag: jpa
Spring Data JPA: What is wrong or how to correct this jpql query
The entity relationships are – A student belongs to one college And a college can have multiple students. So there is ManyToOne relationship between Student –> College And a OneToMany relationship between College –> Student. The entities are as below. and 1) I am using the below jpql q…
How does JPA EntityGraph allow chosing the entity graph at runtime?
I have seen various post describing that JPA EntityGraph allows to choose the graph at run time. And I am not entirely clear what this refers to. Out of good faith and respect I would like to take this helpful article for reference: https://www.baeldung.com/jpa-entity-graph. (Most of JPA users might have gone…
EclipseLink not tracking changes to converted wrapper attributes
I am having problems with EclipseLink change tracking in one of my entity classes in a Java SE application. I am using Java 8, JPA 3.0 provided by EclipseLink 3.0.2 and HyperSQL 2.6.1. So far I have kept my implementation provider-independent, so switching JPA providers is an option, although not preferable. …
JPQL query that give me the highest value
I’m trying to do a JPQL query that give me the highest PK of the PKs in my table (https://drive.google.com/file/d/1_kaklkKdCbhT0-byqCtz6HgfluKKp8J-/view?usp=sharing). Here is my query : The error says that the syntax of my query is wrong. Can someone please help me ? Thank you for your help 🙂 Answer Tha…
JPA pagination query becomes slower with every subsequent call
Project has Spring Boot with JPA. We have a table vehicle with 1m+ records. Table has an indexed field type. We have a use case, where we want to fetch all the records by type. For each type, we get all the vehicle records, then for next type, then for next and so on. Since there are 1m+ records, we
StackOverflowError Springboot OneToMany BiDirectional Mapping
I am currently coding a project, which requires me to map in between two entities: An account and a member. An account can have multiple members, whilst the member can only have one account. After I’ve finished coding the bidirectional way, everything was working and I got the response I wanted, which i…
Nested entities contains null after save
I have an entity with some nested entities like this with entity2 and entity3 like this: Both Entity2 and Entity3 have values stored in the database so when I’m doing an insert on MyEntity, I’m doing this: it works fine, the data are stored correctly in the DB with the correct foreign keys BUTR…
add a dynamic column to an entity without saving it to the table
I have a model class like the following: And the method in a controller to show the output: It does show an output everythin is just fine: And I want to calculate each companies rating while showing data to the end user. So the output should be as follows: Is it posible to add the rating column dynamicly to t…
Java JPA SpringBoot
I have table A and table B, table B have a fk that rererences to table A. class EntityA class EntityB But when i try to call findAll method from repository (from EntityA) i get: Could not write JSON: Infinite recursion Answer I’ve solved the problem using unidirectional relationship. Used this on my Ent…