Announcement Announcement Module
Collapse
No announcement yet.
problem updating parent in parent/child program. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem updating parent in parent/child program.

    Hi all,
    What i want to do is a parent/child program with CRUD operations on both.
    My db is on DB2 for OS390.
    I'm using hibernate 2.1.4 with a type 4 JDBC driver, spring 1.1.3 ad struts.

    My mappings are similar to the followings:

    parent mapping:

    <class name="parent" table="parent">
    <composite-id name="parent_key" class=ParentKey">
    <key-property name="parent_key1" column="key1" type="java.lang.Integer"/>
    <key-property name="parent_key2" column="key2" type="java.sql.Date"/>
    </composite-id>
    <property name="parent_prop1" column="prop1" type="java.lang.Double" />
    <set name="childs" cascade="all" table="child">
    <key>
    <column name="parent_key1"/>
    <column name="parent_key2"/>
    </key>
    <one-to-many class="child"/>
    </set>
    </class>

    child mapping :
    <class name="child" table="child">
    <composite-id name="child_key" class="ChildKey">
    <key-property name="parent_key1" column="parent_key1" type="java.lang.Integer"/>
    <key-property name="parent_key1" column="parent_key2" type="java.sql.Date"/>
    <key-many-to-one name="bank_kod" column="bank_code" class="TheBank" />
    </composite-id>
    <property name="child_prop1" column="child_prop1" type="java.lang.Integer" />
    </class>

    Everything is working ok except updating a parent and deleting a parent with 1 or more childs.

    My update method is
    public void updateParent(Parent parent) {
    getHibernateTemplate().update(parent);
    }

    Following is the trace file:

    DEBUG - ParenTAction.update(128) | entering 'update' method...
    DEBUG - ParentAction.update(142) | Parent@141b736[
    parntkey=ParentKey@1635484[
    parent_key1=2
    parent_key2=2005-12-12
    ]
    parent_prop1=10.0
    childs=[]
    ]
    DEBUG - SessionImpl.<init>(555) | opened session
    DEBUG - JDBCTransaction.begin(37) | begin
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:534)
    ERROR - SessionImpl.execute(2375) | Could not synchronize database state with session
    net.sf.hibernate.JDBCException: could not delete collection: [Parent.childs#ParentKey@1635484[
    parent_key1=2
    parent_key2=2005-12-12
    ]]
    at net.sf.hibernate.collection.AbstractCollectionPers ister.remove(AbstractCollectionPersister.java:496)
    at net.sf.hibernate.impl.ScheduledCollectionRemove.ex ecute(ScheduledCollectionRemove.java:22)
    at net.sf.hibernate.impl.SessionImpl.executeAll(Sessi onImpl.java:2414)
    at net.sf.hibernate.impl.SessionImpl.execute(SessionI mpl.java:2369)
    at net.sf.hibernate.impl.SessionImpl.flush(SessionImp l.java:2236)
    at net.sf.hibernate.transaction.JDBCTransaction.commi t(JDBCTransaction.java:61)
    at org.springframework.orm.hibernate.HibernateTransac tionManager.doCommit(HibernateTransactionManager.j ava:386)
    at org.springframework.transaction.support.AbstractPl atformTransactionManager.commit(AbstractPlatformTr ansactionManager.java:316)
    at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:211)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:148)
    at $Proxy1.updateParent(Unknown Source)
    at ParentAction.update(ParentAction.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:309)
    at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:231)
    at org.springframework.web.struts.DelegatingActionPro xy.execute(DelegatingActionProxy.java:131)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:449)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:264)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1176)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:472)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at com.opensymphony.module.sitemesh.filter.PageFilter .parsePage(PageFilter.java:142)
    at com.opensymphony.module.sitemesh.filter.PageFilter .doFilter(PageFilter.java:58)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:186)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invo keNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(P oolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: KEY1
    at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
    at com.ibm.db2.jcc.b.zc.a(zc.java:1206)
    at com.ibm.db2.jcc.b.zc.a(zc.java:1192)
    at com.ibm.db2.jcc.a.db.h(db.java:142)
    at com.ibm.db2.jcc.a.db.a(db.java:43)
    at com.ibm.db2.jcc.a.r.a(r.java:30)
    at com.ibm.db2.jcc.a.sb.g(sb.java:152)
    at com.ibm.db2.jcc.b.zc.n(zc.java:1186)
    at com.ibm.db2.jcc.b.ad.db(ad.java:1761)
    at com.ibm.db2.jcc.b.ad.d(ad.java:2203)
    at com.ibm.db2.jcc.b.ad.V(ad.java:521)
    at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
    at net.sf.hibernate.impl.NonBatchingBatcher.addToBatc h(NonBatchingBatcher.java:22)
    at net.sf.hibernate.collection.AbstractCollectionPers ister.remove(AbstractCollectionPersister.java:486)
    ... 53 more
    DEBUG - JDBCTransaction.rollback(82) | rollback
    DEBUG - SessionImpl.afterTransactionCompletion(585) | transaction completion
    DEBUG - JDBCTransaction.toggleAutoCommit(103) | re-enabling autocommit
    DEBUG - SessionImpl.close(573) | closing session
    DEBUG - SessionImpl.disconnect(3332) | disconnecting session
    DEBUG - SessionImpl.afterTransactionCompletion(585) | transaction completion
    WARN - RequestProcessor.processException(534) | Unhandled Exception thrown: class org.springframework.dao.DataIntegrityViolationExce ption

    Any idea what is wrong with it?
    Thanks
    Mahmut Eren
Working...
X