openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Lee (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2199) Constraint violation exception when removing relationship using (orphanRemoval = true)
Date Thu, 17 May 2012 16:24:07 GMT
Albert Lee created OPENJPA-2199:

             Summary: Constraint violation exception when removing relationship using (orphanRemoval
= true)
                 Key: OPENJPA-2199
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 2.2.0, 2.1.0, 2.0.0
            Reporter: Albert Lee
            Assignee: Albert Lee

The problem occurs with the following relationships between classes:

Parent ->* Child ->* GrandChild. Class Parent has a collection of Childs.
Class Child has a collection of GrandChilds.
Each one-to-many relationship is annotated like this: @OneToMany(cascade = CascadeType.
ALL, orphanRemoval = true, ...). I.e. we use orphan removal and remove operations cascade
from parents to children and grandchildren.

When we do the following a DB constraint violation occurs:
1) Start a transaction
2) Load a Parent instance from the database
3) Navigate to a Child and modify it
4) Cut the relationship between Child and GrandChild
5) Cut the relationship between Parent and Child
6) Commit the transaction

Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: DELETE on table 'JPAORPHAN_CHILD'
caused a violation of foreign key constraint 'SQL120320110237861' for key (11).  The statement
has been rolled back. {prepstmnt 1074806800 DELETE FROM APP.JPAORPHAN_CHILD WHERE ID = ? [params=(int)
11]} [code=20000, state=23503]

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message