-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: "all-delete-orphan" parent has child and child and
PostPosted: Mon Jun 06, 2005 3:36 pm 
Newbie

Joined: Mon Jun 06, 2005 3:25 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1

My problem is the following: I have a parent who has a child and the child has a bunch of children. The issue is when I delete the parent, I want the child and it's childs' children to be deleted. When I delete the parent, hibernate tries to delete the child but gets a constraintviolationexception cause it cannot delete the child's children. Is this supported?

Mapping documents:
<!-- bi-directional one-to-many association to STaskmappingpartner -->
<set name="STaskmappingpartners" lazy="true" inverse="true" cascade="all-delete-orphan">
<meta attribute="field-description">
@hibernate.set lazy="true" inverse="true" cascade="all,delete-orphan"

@hibernate.collection-key column="PSID"
@hibernate.collection-key column="TASKSYSID"

@hibernate.collection-one-to-many class="com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartner"
</meta>
<key>
<column name="PSID" />
<column name="TASKSYSID" />
</key>
<one-to-many class="com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartner" />
</set>
*****************************************************
<!-- bi-directional one-to-many association to STaskmpfydetail -->
<set name="STaskmpfydetails" lazy="true" inverse="true" cascade="all-delete-orphan">
<meta attribute="field-description">
@hibernate.set lazy="true" inverse="true" cascade="none"

@hibernate.collection-key column="MPORGID"
@hibernate.collection-key column="PSID"
@hibernate.collection-key column="TASKSYSID"

@hibernate.collection-one-to-many class="com.mapmodteam.mip.pa.data.hibernate.STaskmpfydetail"
</meta>
<key>
<column name="MPORGID" />
<column name="PSID" />
<column name="TASKSYSID" />
</key>
<one-to-many class="com.mapmodteam.mip.pa.data.hibernate.STaskmpfydetail" />
</set>

********************************************************

<!-- bi-directional many-to-one association to STaskmappingpartner -->
<many-to-one name="STaskmappingpartner" class="com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartner" update="false" insert="false" cascade="delete" >
<meta attribute="field-description">@hibernate.many-to-one update="false" insert="false"</meta>
<meta attribute="field-description">@hibernate.column name="MPORGID"</meta>
<meta attribute="field-description">@hibernate.column name="PSID"</meta>
<meta attribute="field-description">@hibernate.column name="TASKSYSID"</meta>
<column name="MPORGID" />
<column name="PSID" />
<column name="TASKSYSID" />
</many-to-one>

****************************************************


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
[DEBUG] - [2005.06.06.14:11:48] - [net.sf.hibernate.util.JDBCExceptionReporter] - [ could not delete: [com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartner#com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartnerPK@5d8fdb2[psid=1100840,tasksysid=1100984,mporgid=2719]] ] - [net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:49)]
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -532, SQLSTATE: 23504, SQLERRMC: MNGMT43A.S_TASKMPFYDETAIL.SQL050104101330920
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.hibernate.HibernateAccess.endHibernateTransaction(HibernateAccess.java:257)
at com.mapmodteam.mip.pa.bridge.common.TransactionManager.executeTransaction(TransactionManager.java:546)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:74)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:601)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
[ WARN] - [2005.06.06.14:11:48] - [net.sf.hibernate.util.JDBCExceptionReporter] - [ SQL Error: -532, SQLState: 23504 ] - [net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:57)]
[ERROR] - [2005.06.06.14:11:48] - [net.sf.hibernate.util.JDBCExceptionReporter] - [ DB2 SQL error: SQLCODE: -532, SQLSTATE: 23504, SQLERRMC: MNGMT43A.S_TASKMPFYDETAIL.SQL050104101330920 ] - [net.sf.hibernate.util.JDBCExceptionReporter.logExceptions(JDBCExceptionReporter.java:58)]
[ERROR] - [2005.06.06.14:11:48] - [net.sf.hibernate.impl.SessionImpl] - [ Could not synchronize database state with session ] - [net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2399)]
[DEBUG] - [2005.06.06.14:11:48] - [net.sf.hibernate.transaction.JDBCTransaction] - [ rollback ] - [net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:82)]
[DEBUG] - [2005.06.06.14:11:48] - [net.sf.hibernate.impl.SessionImpl] - [ transaction completion ] - [net.sf.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:594)]
[FATAL] - [2005.06.06.14:11:48] - [com.mapmodteam.mip.pa.hibernate.HibernateAccess] - [ Problem committing Hibernate Transaction ] - [com.mapmodteam.mip.pa.hibernate.HibernateAccess.commitHibernateTransaction(HibernateAccess.java:271)]
net.sf.hibernate.exception.ConstraintViolationException: could not delete: [com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartner#com.mapmodteam.mip.pa.data.hibernate.STaskmappingpartnerPK@5d8fdb2[psid=1100840,tasksysid=1100984,mporgid=2719]]
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at com.mapmodteam.mip.pa.hibernate.HibernateAccess.commitHibernateTransaction(HibernateAccess.java:268)
at com.mapmodteam.mip.pa.hibernate.HibernateAccess.endHibernateTransaction(HibernateAccess.java:255)
at com.mapmodteam.mip.pa.bridge.common.TransactionManager.executeTransaction(TransactionManager.java:545)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:74)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:601)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
Caused by:
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -532, SQLSTATE: 23504, SQLERRMC: MNGMT43A.S_TASKMPFYDETAIL.SQL050104101330920
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.hibernate.HibernateAccess.endHibernateTransaction(HibernateAccess.java:257)
at com.mapmodteam.mip.pa.bridge.common.TransactionManager.executeTransaction(TransactionManager.java:546)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.updateStudies(DataDevelopmentTransactionBridge.java:77)
at com.mapmodteam.mip.pa.bridge.datadevelopment.DataDevelopmentTransactionBridge.main(DataDevelopmentTransactionBridge.java:602)
... 5 more
Name and version of the database you are using:

============================================================
About DB2 Administration Tools Environment
============================================================
DB2 administration tools level:
Product identifier SQL08020
Level identifier 03010106
Level DB2 v8.1.7.445
Build level s040812
PTF WR21342
============================================================
Java development kit (JDK):
Level IBM Corporation 1.4.1
============================================================



The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.