Skip to content
Advertisement

Tag: jpa

Spring – how to automatically insert an entity in the database when inserting another (One-To-One relationship)?

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 for the drivers to register in the system: How would you Actually

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 Thank you for your comments ! It allowed me to solve

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 BUT… After insert I want to build

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 EntityA and erase the property entityA on

Advertisement