Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Integrity constraint violation on join table involved in cascade delete; using HSQL

EclipseLink will delete from all join tables up front, so I can't see how
this could occur.

Please include the log on finest, and your classes code.


daverino wrote:
> 
> Hello,
> I'm having a problem similar to the one reported in bug 221389, but my
> model is a little different and I'm using EclipseLink 2.1.0, which should
> have the fix for the aforementioned bug.  So I think it's a similar bug
> that still exists in 2.1.0.
> 
> I have only made use of standard JPA annotations to map my classes.  I
> have an entity (E1) with a 1xM relationship to an abstract entity (aaE2)
> that has two levels of entities inheriting from it (aE2 and E2).  The
> immediate abstract child of the abstract entity at the M side of the
> relationship (aE2) has a 1xM relationship to another entity (E3) that
> inherits from an abstract MappedSuperclass (aMS3).
> 
> aaE2<--aE2<--E2
> M        1
> x         x
> 1        M
> E1      E3-->aMS3
> 
> I have cascade remove applied to the above relationships (actually, all
> cascade types).  I used the JOINED inheritance strategy for E2. 
> EclipseLink creates join tables for each of the 1xM relationships above.
> 
> When I delete an instance of E1 that has instances of E2, which in turn
> has instances of E3, EclipseLink attempts to delete from the table for E3
> before it deletes from the join table linking aE2 and E3. 
> 
> I get the following exception:
> 
> Exception [EclipseLink-4002] (Eclipse Persistence Services -
> 2.1.0.v20100614-r7608):
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: java.sql.SQLException: Integrity constraint violation
> <constraint_name> table: <aE2 1xM E3>) in statement [DELETE FROM <E3>
> WHERE (<primary_key> = ?)]
> Error Code: -8
> 
> where <constraint_name> is the name of the constraint being violated, <aE2
> 1xM E3> is the name of the join table linking aE2 and E3, <E3> is the name
> of the table for E3, and <primary_key> is the name of the primary key in
> <E3>.
> 
> I believe this is this a bug because EclipseLink should be deleting rows
> from <aE2 1xM E3> before deleting from <E3>.
> 
> It works in Hibernate 3.5.3, too.
> 
> Thanks,
> Dave
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Integrity-constraint-violation-on-join-table-involved-in-cascade-delete--using-HSQL-tp29474882p29523316.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top