-->
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.  [ 6 posts ] 
Author Message
 Post subject: Update statement created when deleting a collection.
PostPosted: Fri Nov 03, 2006 1:55 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hello,

I am trying to delete a collection of a parent object and once I issue the delete and commit commands Hibernate throws a stack trace. I have looked into the issue and it appears that Hibernate is trying to execute an "UPDATE" statement with "nulls" in the key fields on the child within the collection. This is causing DB2 to complain about nulls in a non null field.
I have included the parent and child hbm files. I am sure I can solve this issue by doing a native SQLQuery, but I would like to use Hibernate functionality whenever possible. It is quite possible that I have a mapping issue, but I cannot see the problem.

Any help would be greatly appreciated!


Hibernate version:
3.2.0 GA

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping package="us.nc.state.doc.ws.hibernate.bean.offender" default-lazy="false" >
<class name="Ofnt7ih1" table="OFNV7IH1">
<composite-id name="id" class="Ofnt7ih1Id">
<key-property name="facilityId" type="string" column="CFFACLID" length="5" />
<key-property name="offenderNumber" type="string" column="CMDORNUM" length="7" />
<key-property name="intakeDate" type="date" column="INTKDATE" length="10" />
</composite-id>
<property name="intakeStatus" type="string" column="INTKSTAT" length="3" not-null="true" />
<property name="statusDate" type="date" column="STATUSDATE" length="10" not-null="true" />
<property name="dateOfEntry" type="date" column="DTOFENTRY" length="10" not-null="true" />
<property name="timestampOfEntry" type="timestamp" column="TSOFUPDT" length="26" not-null="true" />
<property name="staffOfUpdate" type="string" column="STFOFUPDT" length="5" not-null="true" />
<set name="detailItems" cascade="all" inverse="false" lazy="false">
<key>
<column name="CFFACLID"/>
<column name="CMDORNUM"/>
<column name="INTKDATE"/>
</key>
<one-to-many class="Ofnt7id1"/>
</set>
</class>
</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping package="us.nc.state.doc.ws.hibernate.bean.offender">
<class name="Ofnt7id1" table="OFNV7ID1">
<composite-id name="id" class="Ofnt7id1Id">
<key-property name="facilityId" type="string" column="CFFACLID" length="5" />
<key-property name="offenderNumber" type="string" column="CMDORNUM" length="7" />
<key-property name="intakeDate" type="date" column="INTKDATE" length="10" />
<key-property name="intakeTask" type="string" column="INTKTASK" length="3" />
<key-property name="timestampOfCreate" type="timestamp" column="TSOFCREAT" length="26" />
</composite-id>
<property name="staffIdOfInterview" type="string" column="INTKSTFID" length="5" not-null="true" />
<property name="taskDate" type="date" column="INTKTASKDT" length="10" not-null="true" />
<property name="interviewResponsibility" type="string" column="INTKRESP" length="2" not-null="true" />
<property name="interviewTaskOrder" type="long" column="INTKORDR" precision="4" scale="0" not-null="true" />
<property name="interviewTaskStatus" type="string" column="INTKSTFLG" length="1" not-null="true" />
<property name="timestampOfUpdate" type="timestamp" column="TSOFUPDT" length="26" not-null="true" />
<property name="staffOfUpdate" type="string" column="STFOFUPDT" length="5" not-null="true" />
</class>
</hibernate-mapping>


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

HibernateSessionFactory.beginTransaction();

//Merge the Inmt9aa1 object...
Inmt9aa1DAO oInmt9aa1DAO = new Inmt9aa1DAO();
Inmt9aa1 oInmt9aa1 = oInmt9aa1DAO.findById(p_strOffenderNbr);
if (oInmt9aa1 == null) {
throw new FacadeException("Transportation record (inmt9aa1) was not found.");
}
oInmt9aa1.setOffenderNumber(p_strMergeOffenderNbr);

//Merge the Ofnt7ih object...
Ofnt7ih1DAO oOfnt7ih1DAO = new Ofnt7ih1DAO();
Date dtScheduledArrivalProcessDate = DateUtils
.parseStringToDate(p_strScheduledArrivalProcessDate,
DateUtils.yyyy_MM_dd);
Ofnt7ih1 oOldOfnt7ih1 = oOfnt7ih1DAO.findByPK(new Ofnt7ih1Id(p_strFacilityId,
p_strOffenderNbr,
dtScheduledArrivalProcessDate));
if (oOldOfnt7ih1 == null) {
throw new FacadeException("Offender Reception Header record (Ofnt7ih1) was not found.");
}
Ofnt7ih1 oNewOfnt7ih1 = new Ofnt7ih1();
oNewOfnt7ih1.setId(new Ofnt7ih1Id(p_strFacilityId,
p_strMergeOffenderNbr,
dtScheduledArrivalProcessDate));

oNewOfnt7ih1.setDateOfEntry(oOldOfnt7ih1.getDateOfEntry());
oNewOfnt7ih1.setStaffOfUpdate(oOldOfnt7ih1.getStaffOfUpdate());
oNewOfnt7ih1.setStatusDate(oOldOfnt7ih1.getStatusDate());
//If intake status has been provided then update
//the header record.
if (StringUtils.isNotEmpty(p_strIntakeStatus)) {
oNewOfnt7ih1.setIntakeStatus(p_strIntakeStatus);
oNewOfnt7ih1.setTimestampOfEntry(new Date());
}
else {
oNewOfnt7ih1.setIntakeStatus(oOldOfnt7ih1.getIntakeStatus());
oNewOfnt7ih1.setTimestampOfEntry(oOldOfnt7ih1.getTimestampOfEntry());
}
for (Ofnt7id1 oOldOfnt7id1 : oOldOfnt7ih1.getDetailItems()) {
Ofnt7id1 oNewOfnt7id1 = new Ofnt7id1();
oNewOfnt7id1.setId(new Ofnt7id1Id(p_strFacilityId,
p_strMergeOffenderNbr,
oOldOfnt7id1.getId().getIntakeDate(),
oOldOfnt7id1.getId().getIntakeTask(),
oOldOfnt7id1.getId().getTimestampOfCreate()));

oNewOfnt7id1.setInterviewResponsibility(oOldOfnt7id1.getInterviewResponsibility());
oNewOfnt7id1.setInterviewTaskOrder(oOldOfnt7id1.getInterviewTaskOrder());
oNewOfnt7id1.setInterviewTaskStatus(oOldOfnt7id1.getInterviewTaskStatus());
oNewOfnt7id1.setStaffIdOfInterview(oOldOfnt7id1.getStaffIdOfInterview());
oNewOfnt7id1.setStaffOfUpdate(oOldOfnt7id1.getStaffOfUpdate());
oNewOfnt7id1.setTaskDate(oOldOfnt7id1.getTaskDate());
oNewOfnt7id1.setTimestampOfUpdate(new Date());
for (TaskItem oTaskItem : p_oTaskList) {
if (oTaskItem.getTaskType()
.equals(oNewOfnt7id1.getId().getIntakeTask())) {
oNewOfnt7id1.setStaffIdOfInterview(oTaskItem.getTaskStaffId());
oNewOfnt7id1.setTaskDate(oTaskItem.getTaskDate());
oNewOfnt7id1.setStaffOfUpdate("");
}
}//END..while (taskIter.hasNext())

//Add to the parent object...
oNewOfnt7ih1.addOfnt7id1(oNewOfnt7id1);
}

oOldOfnt7ih1.removeAllDetailItems();
oOfnt7ih1DAO.delete(oOldOfnt7ih1);

HibernateSessionFactory.commitTransaction();

Full stack trace of any exception that occurs:

12:34:33,992 INFO [STDOUT] Hibernate: update HZAZDB3.OFNV7ID1 set CFFACLID=null, CMDORNUM=null, INTKDATE=null where CFFACLID=? and CMDORNUM=? and INTKDATE=?
12:34:33,992 INFO [STDOUT] Nov 03 2006 12:34:33 DEBUG [AbstractBatcher] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:34:33,992 INFO [STDOUT] Nov 03 2006 12:34:33 DEBUG [AbstractCollectionPersister] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) Deleting collection: [us.nc.state.doc.ws.hibernate.bean.offender.Ofnt7ih1.detailItems#component[facilityId,offenderNumber,intakeDate]{intakeDate=25 October 2006, facilityId=3060 , offenderNumber=T347170}]
12:34:33,992 INFO [STDOUT] Nov 03 2006 12:34:33 DEBUG [AbstractBatcher] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:34:34,242 INFO [STDOUT] Nov 03 2006 12:34:34 DEBUG [AbstractBatcher] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:34:34,242 INFO [STDOUT] Nov 03 2006 12:34:34 DEBUG [JDBCExceptionReporter] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) could not delete collection: [us.nc.state.doc.ws.hibernate.bean.offender.Ofnt7ih1.detailItems#component[facilityId,offenderNumber,intakeDate]{intakeDate=25 October 2006, facilityId=3060 , offenderNumber=T347170}] [update HZAZDB3.OFNV7ID1 set CFFACLID=null, CMDORNUM=null, INTKDATE=null where CFFACLID=? and CMDORNUM=? and INTKDATE=?]
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0407N Assignment of a NULL value to a NOT NULL column "CFFACLID" is not allowed. SQLSTATE=23502

at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1048)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at us.nc.state.doc.ws.core.hibernate.HibernateSessionFactory.commitTransaction(HibernateSessionFactory.java:157)
at us.nc.state.doc.ws.facade.misc.OffenderReceptionFacade.offenderReceptionMerge(OffenderReceptionFacade.java:725)
at us.nc.state.doc.services.misc.OffenderReceptionSkeleton.OffndrRcptMerge(OffenderReceptionSkeleton.java:331)
at us.nc.state.doc.services.misc.OffenderReceptionMessageReceiverInOut.invokeBusinessLogic(OffenderReceptionMessageReceiverInOut.java:182)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:493)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:323)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:234)
at us.nc.state.doc.servlet.Axis2ServletImpl.doPost(Axis2ServletImpl.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:217)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
12:34:34,242 INFO [STDOUT] Nov 03 2006 12:34:34 WARN [JDBCExceptionReporter] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) SQL Error: -407, SQLState: 23502
12:34:34,242 INFO [STDOUT] Nov 03 2006 12:34:34 ERROR [JDBCExceptionReporter] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) [IBM][CLI Driver][DB2] SQL0407N Assignment of a NULL value to a NOT NULL column "CFFACLID" is not allowed. SQLSTATE=23502
12:34:34,242 INFO [STDOUT] Nov 03 2006 12:34:34 ERROR [AbstractFlushingEventListener] [ThreadId:http-0.0.0.0-8080-1] (AppId:ORP RemoteAddr:127.0.0.1 UserId:ts73p61) Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not delete collection: [us.nc.state.doc.ws.hibernate.bean.offender.Ofnt7ih1.detailItems#component[facilityId,offenderNumber,intakeDate]{intakeDate=25 October 2006, facilityId=3060 , offenderNumber=T347170}]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1071)
at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at us.nc.state.doc.ws.core.hibernate.HibernateSessionFactory.commitTransaction(HibernateSessionFactory.java:157)
at us.nc.state.doc.ws.facade.misc.OffenderReceptionFacade.offenderReceptionMerge(OffenderReceptionFacade.java:725)
at us.nc.state.doc.services.misc.OffenderReceptionSkeleton.OffndrRcptMerge(OffenderReceptionSkeleton.java:331)
at us.nc.state.doc.services.misc.OffenderReceptionMessageReceiverInOut.invokeBusinessLogic(OffenderReceptionMessageReceiverInOut.java:182)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:493)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:323)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:234)
at us.nc.state.doc.servlet.Axis2ServletImpl.doPost(Axis2ServletImpl.java:109)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:217)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0407N Assignment of a NULL value to a NOT NULL column "CFFACLID" is not allowed. SQLSTATE=23502

at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1048)
... 42 more


Name and version of the database you are using:
DB2 version 8

The generated SQL (show_sql=true):

update HZAZDB3.OFNV7ID1 set CFFACLID=null, CMDORNUM=null, INTKDATE=null where CFFACLID=? and CMDORNUM=? and INTKDATE=?

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

No

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 2:43 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hello,

I have debugged the issue some more. I have found that the "OneToManyPersister" has a method called generateDeleteString(). See below

Shouldn't this method be creating a delete sql statement ?


/**
* Generate the SQL UPDATE that updates all the foreign keys to null
*/
protected String generateDeleteString() {

Update update = new Update( getDialect() )
.setTableName( qualifiedTableName )
.addColumns( keyColumnNames, "null" )
.setPrimaryKeyColumnNames( keyColumnNames );

if ( hasIndex && !indexContainsFormula ) update.addColumns( indexColumnNames, "null" );

if ( hasWhere ) update.setWhere( sqlWhereString );

if ( getFactory().getSettings().isCommentsEnabled() ) {
update.setComment( "delete one-to-many " + getRole() );
}

return update.toStatementString();
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
eh no, delete a one-to-many collection is done by updating the tables that points to it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 3:04 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hi Max,

The 3 fields that are trying to be updated are 3 primary keys from the child table.


I am trying to map a set of children to the parent. The 3 primary keys from the parent map to the first 3 primary keys of the child. There is a total of 5 primary keys for the children.

Have I configured my mappings incorrectly ?

Again, thanks for the help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 3:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so this is not a collection you can delete; only read.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 03, 2006 3:39 pm 
Newbie

Joined: Fri Jul 07, 2006 9:36 am
Posts: 15
Hi Max,

I guess that would be true. It is read, create and update only seeing how Hibernate works with this collection.

Did I map the config files correctly ? Is there another solution ?

I am ready to implement a native sql statement to delete both the parent and children.


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.