[JBoss-dev] [JBoss JIRA] Commented: (JBAS-32) Exception is thrown when removing entity with null/invalid CMR value

2004-12-08 Thread Alex Loubyansky (JIRA)
 [ http://jira.jboss.com/jira/browse/JBAS-32?page=comments#action_12310751 ]
 
Alex Loubyansky commented on JBAS-32:
-

 If this is the case, how do I make CMR work for child 4?

Either set the foreign key to null or create a parent with pk 3.

 I was thinking the fk-constraint tag in the DD tells the container to check 
 data integrity for all operations (i.e. insert, update and delete).

fk-constraint tag is used only for database schema generation, i.e. it 
indicates whether the foreign key constraint should be created when JBossCMP 
creates tables.

 Why not the container just removes child 4 when there is no cascade-delete 
 requirement?

Because before removal, the instance should be removed from all the container 
managed relationships it participates in. The indicator of existing 
relationship is non-null foreign key value.

 Exception is thrown when removing entity with null/invalid CMR value
 

  Key: JBAS-32
  URL: http://jira.jboss.com/jira/browse/JBAS-32
  Project: JBoss Application Server
 Type: Bug
   Components: CMP service
 Versions: JBossAS-4.0.0 Final, JBossAS-3.2.6 Final
 Reporter: Sonnel Pun
 Assignee: Scott M Stark



 Let's look at the following example.
 T_Parent
 ==
 (pk)
 --
   1
   2
 T_Child
 ==
 (pk)   (fk)
 --
   1  1
   2  1
   3 null
   4  3
 Let say, table T_Child and T_Parent have a 1-M relationship.
 This relationship is modelled using CMR such that, no fk constraint and 
 cascade 
 delete is required. It is fine when removing the record 1 and 2 from T_Child 
 but 
 when removing records 3 and 4, exception is thrown.
 Here is the stack trace
 --
 16:00:37,108 ERROR [LogInterceptor] TransactionRolledbackLocalException in 
 method: null, causedBy:
 javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=[.0.]
   at 
 org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:182)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:342)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
   at 
 org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
   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:514)
   at org.jboss.ejb.Container.invoke(Container.java:854)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeRemoveRelation(JDBCCMRFieldBridge.java:1211)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1026)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1012)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:996)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:890)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$NoneCascadeDeleteStrategy.removedIds(CascadeDeleteStrategy.java:52)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.removeFromRelations(JDBCCMRFieldBridge.java:393)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.removeFromRelations(JDBCEntityBridge.java:308)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:91)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:682)
   at 
 org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:506)
   at 
 org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:454)
   at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:530)
   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.invocation.Invocation.performCall(Invocation.java:345)
   at 
 org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1159)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
   at 
 org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:273)
   at 
 

[JBoss-dev] [JBoss JIRA] Commented: (JBAS-32) Exception is thrown when removing entity with null/invalid CMR value

2004-12-07 Thread Alex Loubyansky (JIRA)
 [ http://jira.jboss.com/jira/browse/JBAS-32?page=comments#action_12310736 ]
 
Alex Loubyansky commented on JBAS-32:
-

Child 4 references non-existing parent 3. So it is expected to fail.
Child 3 should be removed successfully. What is the code and deployment 
descriptors for Child and Parent?
Thanks.

 Exception is thrown when removing entity with null/invalid CMR value
 

  Key: JBAS-32
  URL: http://jira.jboss.com/jira/browse/JBAS-32
  Project: JBoss Application Server
 Type: Bug
   Components: CMP service
 Versions: JBossAS-3.2.6 Final, JBossAS-4.0.0 Final
 Reporter: Sonnel Pun
 Assignee: Scott M Stark



 Let's look at the following example.
 T_Parent
 ==
 (pk)
 --
   1
   2
 T_Child
 ==
 (pk)   (fk)
 --
   1  1
   2  1
   3 null
   4  3
 Let say, table T_Child and T_Parent have a 1-M relationship.
 This relationship is modelled using CMR such that, no fk constraint and 
 cascade 
 delete is required. It is fine when removing the record 1 and 2 from T_Child 
 but 
 when removing records 3 and 4, exception is thrown.
 Here is the stack trace
 --
 16:00:37,108 ERROR [LogInterceptor] TransactionRolledbackLocalException in 
 method: null, causedBy:
 javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=[.0.]
   at 
 org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:182)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:342)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
   at 
 org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
   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:514)
   at org.jboss.ejb.Container.invoke(Container.java:854)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeRemoveRelation(JDBCCMRFieldBridge.java:1211)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1026)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1012)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:996)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:890)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$NoneCascadeDeleteStrategy.removedIds(CascadeDeleteStrategy.java:52)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.removeFromRelations(JDBCCMRFieldBridge.java:393)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.removeFromRelations(JDBCEntityBridge.java:308)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:91)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:682)
   at 
 org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:506)
   at 
 org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:454)
   at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:530)
   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.invocation.Invocation.performCall(Invocation.java:345)
   at 
 org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1159)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
   at 
 org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:273)
   at 
 org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at 
 org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:111)
   at 
 org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:211)
   at 
 org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:89)
   at 
 org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterceptor.java:53)
   at 
 

[JBoss-dev] [JBoss JIRA] Commented: (JBAS-32) Exception is thrown when removing entity with null/invalid CMR value

2004-12-07 Thread Sonnel Pun (JIRA)
 [ http://jira.jboss.com/jira/browse/JBAS-32?page=comments#action_12310746 ]
 
Sonnel Pun commented on JBAS-32:


 Child 4 references non-existing parent 3. So it is expected to fail.

If this is the case, how do I make CMR work for child 4?
I was thinking the fk-constraint tag in the DD tells the container to check 
data integrity for all operations (i.e. insert, update and delete). Why not the 
container just removes child 4 when there is no cascade-delete requirement?


For child 3, it's my problem and I got it fixed. Thanks.

Great work Alexey!

 Exception is thrown when removing entity with null/invalid CMR value
 

  Key: JBAS-32
  URL: http://jira.jboss.com/jira/browse/JBAS-32
  Project: JBoss Application Server
 Type: Bug
   Components: CMP service
 Versions: JBossAS-4.0.0 Final, JBossAS-3.2.6 Final
 Reporter: Sonnel Pun
 Assignee: Scott M Stark



 Let's look at the following example.
 T_Parent
 ==
 (pk)
 --
   1
   2
 T_Child
 ==
 (pk)   (fk)
 --
   1  1
   2  1
   3 null
   4  3
 Let say, table T_Child and T_Parent have a 1-M relationship.
 This relationship is modelled using CMR such that, no fk constraint and 
 cascade 
 delete is required. It is fine when removing the record 1 and 2 from T_Child 
 but 
 when removing records 3 and 4, exception is thrown.
 Here is the stack trace
 --
 16:00:37,108 ERROR [LogInterceptor] TransactionRolledbackLocalException in 
 method: null, causedBy:
 javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=[.0.]
   at 
 org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:182)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:342)
   at 
 org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
   at 
 org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
   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:514)
   at org.jboss.ejb.Container.invoke(Container.java:854)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeRemoveRelation(JDBCCMRFieldBridge.java:1211)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1026)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:1012)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.destroyRelationLinks(JDBCCMRFieldBridge.java:996)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JDBCCMRFieldBridge.java:890)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.CascadeDeleteStrategy$NoneCascadeDeleteStrategy.removedIds(CascadeDeleteStrategy.java:52)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.removeFromRelations(JDBCCMRFieldBridge.java:393)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.removeFromRelations(JDBCEntityBridge.java:308)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRemoveEntityCommand.execute(JDBCRemoveEntityCommand.java:91)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.removeEntity(JDBCStoreManager.java:682)
   at 
 org.jboss.ejb.plugins.CMPPersistenceManager.removeEntity(CMPPersistenceManager.java:506)
   at 
 org.jboss.resource.connectionmanager.CachedConnectionInterceptor.removeEntity(CachedConnectionInterceptor.java:454)
   at org.jboss.ejb.EntityContainer.remove(EntityContainer.java:530)
   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.invocation.Invocation.performCall(Invocation.java:345)
   at 
 org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:1159)
   at 
 org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationInterceptor.java:72)
   at 
 org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:273)
   at 
 org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
   at 
 org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInterceptor.java:111)
   at 
 org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:211)
   at