Deep diving into Spring JPA and I have troubles to understand whats going on here. This is the code: Entity SpringBootApp By starting the app, the following gets generated in the DB: I get to the point where all the persons are generated, but I would expect one additional entry in the PERSONP_KNOWS table, e.g…
Tag: jpa-2.0
How to detach an entity from an EntityManager
My environment Java 7/JPA 2/Hibernate 5.1. My Scenario I’m building a Repository pattern implementation. All code is written and it all works fine when no error condition happens. However, let’s say that three entity instances are added to the repository. First and third are ok, but second lacks v…
java.lang.IllegalStateException: Multiple representations of the same entity with @ManyToMany 3 entities
I have 3 entities with ManyToMany relationships: Role Entity: Permission Entity: Functionality Entity: I did the following: I have created 3 functionalities: Then created 2 permissions: Then created a role: I am getting the following exception: java.lang.IllegalStateException: Multiple representations of the …
JPA: unidirectional many-to-one and cascading delete
Say I have a unidirectional @ManyToOne relationship like the following: If I have a parent P and children C1…Cn referencing back to P, is there a clean and pretty way in JPA to automatically remove the children C1…Cn when P is removed (i.e. entityManager.remove(P))? What I’m looking for is a…