Foreign key violation because jointable row is not removed [message #915956] |
Tue, 18 September 2012 05:41  |
Eclipse User |
|
|
|
Hi,
I've been experiencing foreign key violation whil trying to update a set of entities. These entities together form a tree-like structure, which is saved completely in one go (CascadeType.ALL and orphanRemoval=true is set on all relations). Given the following structure (letters stand for entity types):
A -> B -> B ... B -> C -> D -> [E,F,G]
-> B ... B -> C -> D -> [E,F,G]
All relations are @OneToMany and bi-directional, except the relation between D and E,F,G. E, F and G share a common super class (marked as entity). The relation is privately owned/uni-directional. This relation is also configured to use a @JoinTable
The following scenario fails:
- Initially the first row is in the database and retrieved
- The first row is removed starting from the second B
- The second row is added (effectively replacing the original row)
- The complete set is stored
In the logging I case see that EclipseLink first tries to remove [E,F,G], before removing the row in the @JoinTable, causing a SQL Integraty exception obviously.
Traced from the EclipseLink (2.3.3) code, this starts from ManyToManyMapping.java line 945 (which seems strange, the mapping is OneToMany??).
Tested EclipseLink 2.3.0 - 2.3.3, same result for each
Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=350599 seems related by the description?
Any ideas?
- Am I expecting behaviour from JPA/EclipseLink which is outside of the spec or is this a bug?
- Any ideas for a workaround for this issue?
Thanks.
Jeroen
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03642 seconds