6 Replies Latest reply on Aug 19, 2004 9:44 AM by suzyrizzo

    Foreign key violation - why is child deleted first in 1-1 re

    suzyrizzo

      I am having trouble setting up a relationship in my deployment descriptors for a simple relationship in my database.

      I have two tables, Group and Address. A group has zero or one physical addresses. There is a foreign key on
      Group.PhysicalAddressKey that forces the existance of a related address. An address isn't directly related
      back to a group because address is used for various entities - Group, Member, Company, etc. Therefore, I'm trying
      to set up a uni-directional relationship between a Group and its physical address. When a Group is deleted from the
      database, I would like its related physical address to be deleted, too.

      More specifically, here's what I would like to happen:
      1. Update Group, set physicalAddressKey = NULL
      2. Delete Address record
      3. Delete Group record

      What seems to be happening (from the log) is:
      1. Delete Address record
      2. Foreign key violation
      Specifically:

      2004-08-16 08:03:46,406 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.Group#findByPrimaryKey] Executing SQL: SELECT t0_Group.groupKey FROM CdhpGroup t0_Group WHERE t0_Group.groupKey=?
      2004-08-16 08:03:46,406 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Group] Executing SQL: SELECT groupName, physicalAddressKey, mailingAddressKey, feeBankAccountNumber, feeBankKey, createEnrollmentVerificationLetterInd, createDateTime, createUserId, lastUpdateDateTime, lastUpdateUserId FROM CdhpGroup WHERE (groupKey=?)
      2004-08-16 08:03:46,421 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT groupKey, effDate FROM CDHPGroupId WHERE (groupKey=?)
      2004-08-16 08:03:46,437 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT benefitPlanKey FROM CDHPBenefitPlan WHERE (groupKey=?)
      2004-08-16 08:03:46,453 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT physicalAddressKey FROM CdhpGroup WHERE (groupKey=?)
      2004-08-16 08:03:46,500 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Address] Executing SQL: DELETE FROM CDHPAddress WHERE addressKey=?
      2004-08-16 08:03:46,515 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Address] Could not remove 3
      java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]DELETE statement conflicted with COLUMN REFERENCE constraint 'FK__CdhpGroup__Physi__6B6FCE9C'. The conflict occurred in database 'ASIFSA', table 'CdhpGroup', column 'PhysicalAddressKey'.
       at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
       at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      ...
      javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
      javax.ejb.RemoveException: Could not remove 3


      I tried removing the foreign key constraint from the database to see what would happen. Everything is happy (except for
      my DBA who insists on the foreign key). The container:
      1. Deletes Address record
      2. Deletes Group record
      2004-08-16 08:05:28,093 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.Group#findByPrimaryKey] Executing SQL: SELECT t0_Group.groupKey FROM CdhpGroup t0_Group WHERE t0_Group.groupKey=?
      2004-08-16 08:05:28,109 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Group] Executing SQL: SELECT groupName, physicalAddressKey, mailingAddressKey, feeBankAccountNumber, feeBankKey, createEnrollmentVerificationLetterInd, createDateTime, createUserId, lastUpdateDateTime, lastUpdateUserId FROM CdhpGroup WHERE (groupKey=?)
      2004-08-16 08:05:28,109 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT groupKey, effDate FROM CDHPGroupId WHERE (groupKey=?)
      2004-08-16 08:05:28,125 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT benefitPlanKey FROM CDHPBenefitPlan WHERE (groupKey=?)
      2004-08-16 08:05:28,125 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT physicalAddressKey FROM CdhpGroup WHERE (groupKey=?)
      2004-08-16 08:05:28,140 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Address] Executing SQL: DELETE FROM CDHPAddress WHERE addressKey=?
      2004-08-16 08:05:28,156 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Group] Executing SQL: DELETE FROM CdhpGroup WHERE groupKey=?


      Here is the relationship from ejb-jar.xml:
       <ejb-relation >
       <ejb-relation-name>group-physicaladdress</ejb-relation-name>
      
       <ejb-relationship-role >
       <ejb-relationship-role-name>physicaladdress-has-group</ejb-relationship-role-name>
       <multiplicity>One</multiplicity>
       <cascade-delete/>
       <relationship-role-source >
       <ejb-name>Address</ejb-name>
       </relationship-role-source>
       </ejb-relationship-role>
      
       <ejb-relationship-role >
       <ejb-relationship-role-name>group-has-physicaladdress</ejb-relationship-role-name>
       <multiplicity>One</multiplicity>
       <relationship-role-source >
       <ejb-name>Group</ejb-name>
       </relationship-role-source>
       <cmr-field >
       <cmr-field-name>physicalAddress</cmr-field-name>
       </cmr-field>
       </ejb-relationship-role>
      
       </ejb-relation>


      And the relationship in jbosscmp-jdbc.xml:
       <ejb-relation>
       <ejb-relation-name>group-physicaladdress</ejb-relation-name>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>
       physicaladdress-has-group
       </ejb-relationship-role-name>
       <key-fields>
       <key-field>
       <field-name>addressKey</field-name>
       <column-name>physicalAddressKey</column-name>
       </key-field>
       </key-fields>
       </ejb-relationship-role>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>
       group-has-physicaladdress
       </ejb-relationship-role-name>
       <key-fields/>
       </ejb-relationship-role>
      
       </ejb-relation>


      I'm sure I must be missing a simple configuration option.

      It's almost funny. A while back, I had to use the <batch-cascade-delete> element in jbosscmp-jdbc.xml to force this
      delete-child-first behavior (it was a different situation, 1-many relationship with non-nullable keys). But
      now, the container looks as if it's using the <batch-cascade-delete> functionality when I don't want it.

      For what it's worth, I am using jboss version 3.2.5, and SQL Server 2000.

      Thanks for any suggestions.
      Sue.

        • 1. Re: Foreign key violation - why is child deleted first in 1-
          aloubyansky

          Can you post the whole stacktrace?

          • 2. Re: Foreign key violation - why is child deleted first in 1-
            suzyrizzo

            Sure. Here is the full stacktrace. Sorry for cutting it short the first time.

            2004-08-17 07:41:29,140 INFO [STDOUT] DEBUG: parameters: 2
            2004-08-17 07:41:29,156 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.Group#findByPrimaryKey] Executing SQL: SELECT t0_Group.groupKey FROM CdhpGroup t0_Group WHERE t0_Group.groupKey=?
            2004-08-17 07:41:29,187 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Group] Executing SQL: SELECT groupName, physicalAddressKey, mailingAddressKey, feeBankAccountNumber, feeBankKey, createEnrollmentVerificationLetterInd, createDateTime, createUserId, lastUpdateDateTime, lastUpdateUserId FROM CdhpGroup WHERE (groupKey=?)
            2004-08-17 07:41:29,203 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT physicalAddressKey FROM CdhpGroup WHERE (groupKey=?)
            2004-08-17 07:41:29,203 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT benefitPlanKey FROM CDHPBenefitPlan WHERE (groupKey=?)
            2004-08-17 07:41:29,218 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.Group] load relation SQL: SELECT groupKey, effDate FROM CDHPGroupId WHERE (groupKey=?)
            2004-08-17 07:41:29,218 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Address] Executing SQL: DELETE FROM CDHPAddress WHERE addressKey=?
            2004-08-17 07:41:29,218 ERROR [org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.Address] Could not remove 3
            java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_CdhpGroup_PhysicalAddress'. The conflict occurred in database 'ASIFSA', table 'CdhpGroup', column 'PhysicalAddressKey'.
             at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
             at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
             at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
             at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
             at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
             at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
             at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
             at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
             at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
             at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
             at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
             at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
             at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
             at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:335)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.executeDeleteSQL(JDBCRemoveEntityCommand.java:155)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:103)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy.invokeRemoveRelated(CascadeDeleteStrategy.java:331)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$DefaultCascadeDeleteStrategy.cascadeDelete(CascadeDeleteStrategy.java:109)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.cascadeDelete(JDBCCMRFieldBridge.java:341)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.cascadeDelete(JDBCEntityBridge.java:326)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:116)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
             at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
             at $Proxy137.remove(Unknown Source)
             at com.asihealth.cdhp.modules.membership.session.GroupServiceBean.deleteGroupData(GroupServiceBean.java:283)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
             at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
             at sun.rmi.transport.Transport$1.run(Transport.java:148)
             at java.security.AccessController.doPrivileged(Native Method)
             at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
             at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
             at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
             at java.lang.Thread.run(Thread.java:534)
            2004-08-17 07:41:29,234 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
            javax.ejb.RemoveException: Could not remove 3
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.executeDeleteSQL(JDBCRemoveEntityCommand.java:160)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:103)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy.invokeRemoveRelated(CascadeDeleteStrategy.java:331)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$DefaultCascadeDeleteStrategy.cascadeDelete(CascadeDeleteStrategy.java:109)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.cascadeDelete(JDBCCMRFieldBridge.java:341)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.cascadeDelete(JDBCEntityBridge.java:326)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:116)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
             at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
             at $Proxy137.remove(Unknown Source)
             at com.asihealth.cdhp.modules.membership.session.GroupServiceBean.deleteGroupData(GroupServiceBean.java:283)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
             at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
             at sun.rmi.transport.Transport$1.run(Transport.java:148)
             at java.security.AccessController.doPrivileged(Native Method)
             at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
             at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
             at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
             at java.lang.Thread.run(Thread.java:534)
            2004-08-17 07:41:29,234 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract void com.asihealth.cdhp.modules.membership.session.GroupService.deleteGroupData(java.math.BigDecimal) throws java.rmi.RemoteException, causedBy:
            javax.ejb.RemoveException: Could not remove 3
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.executeDeleteSQL(JDBCRemoveEntityCommand.java:160)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:103)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy.invokeRemoveRelated(CascadeDeleteStrategy.java:331)
             at org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$DefaultCascadeDeleteStrategy.cascadeDelete(CascadeDeleteStrategy.java:109)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.cascadeDelete(JDBCCMRFieldBridge.java:341)
             at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.cascadeDelete(JDBCEntityBridge.java:326)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:116)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:666)
             at org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:466)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:430)
             at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:500)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1102)
             at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
             at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:317)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:118)
             at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:175)
             at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
             at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:54)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.EntityContainer.internalInvoke(EntityContainer.java:484)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:359)
             at org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:44)
             at $Proxy137.remove(Unknown Source)
             at com.asihealth.cdhp.modules.membership.session.GroupServiceBean.deleteGroupData(GroupServiceBean.java:283)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
             at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
             at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
             at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
             at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:315)
             at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:148)
             at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:120)
             at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
             at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
             at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
             at org.jboss.ejb.Container.invoke(Container.java:723)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:60)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:61)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:53)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:185)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:473)
             at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:360)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:324)
             at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
             at sun.rmi.transport.Transport$1.run(Transport.java:148)
             at java.security.AccessController.doPrivileged(Native Method)
             at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
             at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
             at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
             at java.lang.Thread.run(Thread.java:534)


            • 3. Re: Foreign key violation - why is child deleted first in 1-
              aloubyansky

              I can reproduce this by invoking the remove() method on an instance which does not have the foreign key and the container has synch-on-commit-only set to true. But it's not your case, right?
              If you have a simple testcase, please, open a bug report and attach the testcase. Thanks.

              • 4. Re: Foreign key violation - why is child deleted first in 1-
                suzyrizzo

                No, I don't have synch-on-commit-only set to true.

                I'll try to pair down my code to isolate my problem, and submit a bug report for it.

                I haven't done this before...when you say "bug report" do you mean the bug list on the sourceforge site?

                • 5. Re: Foreign key violation - why is child deleted first in 1-
                  aloubyansky

                  Yes, on the sourceforge.net. Thanks.

                  • 6. Re: Foreign key violation - why is child deleted first in 1-
                    suzyrizzo

                    When I tried to isolate the issue, I realized that the problem only occurred when I had multiple releationships
                    set up for an entity - one with batch-cascade-delete and the other without it.

                    I have uploaded my little test-case along with bug report #1012184

                    Thank you very much for your time.