[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - CMP 2.1 EntityBean on RAW based fields
jcoffee
do-not-reply at jboss.com
Wed Aug 29 05:03:36 EDT 2007
Hi there,
I have an "Instance Per Transaction CMP 2.x EntityBean" with optimistic concurrency. This bean stores primitive arrays in RAW based fields using default AppServer serialization.
In the bean:
public abstract boolean[] getBooleanArray();
| public abstract void setBooleanArray(boolean[] booleanArray);
In the jbosscmp-jdbc.xml:
<cmp-field>
| <field-name>booleanArray</field-name>
| <column-name>BOOLEANARRAY</column-name>
| <jdbc-type>VARBINARY</jdbc-type>
| <sql-type></sql-type>
| </cmp-field>
Now, I find a strange behavior on creation and update of such EntityBeans.
Part one:
I create 10 EntityBeans with data in the RAW based fields which lead to 10 INSERTs on the database. Later - on commit of this transaction - I can see another 10 updates incrementing the optimistic concurrency by 1. These updates come from the synchronization of the GlobalTxEntityMap. Far down in the StoreManager.storeEntity methods I found that these RAW-fields, at least when they contain serialized data, are always reported dirty. This makes the StoreManager update every EntityBean bound to the current TX. Here is the crucial part of the stacktrace from the TxManager.commit up to the update execution:
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:227)
| at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:136)
| at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:651)
| at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:413)
| at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:279)
| at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:743)
| at org.jboss.ejb.GlobalTxEntityMap$2.synchronize(GlobalTxEntityMap.java:134)
| at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:253)
| at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.beforeCompletion(GlobalTxEntityMap.java:302)
| at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1473)
| at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1092)
| at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:306)
| at org.jboss.tm.TxManager.commit(TxManager.java:224)
Part two:
I read a couple of these beans by a finder and make an update on one of them. Before the update is done, all beans read in the finder query are updated incrementing the optimistic concurrency by 1. These updates again come from the synchronization of the GlobalTxEntityMap. This time triggered by EntityContainer.findLocal. Again the StoreManager (may be the JDBCFieldBridge) finds any field with serialized data dirty. So, on the firtst find local all beans bound to the current TX are updated. Here is the stacktrace part from the EntityContainer.findLocal up do the update execution:
at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:227)
| at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:136)
| at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:651)
| at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:413)
| at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:279)
| at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:743)
| at org.jboss.ejb.GlobalTxEntityMap$2.synchronize(GlobalTxEntityMap.java:134)
| at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:253)
| at org.jboss.ejb.GlobalTxEntityMap.synchronizeEntities(GlobalTxEntityMap.java:166)
| at org.jboss.ejb.EntityContainer.synchronizeEntitiesWithinTransaction(EntityContainer.java:122)
| at org.jboss.ejb.EntityContainer.findSingleObject(EntityContainer.java:1083)
| at org.jboss.ejb.EntityContainer.findLocal(EntityContainer.java:663)
My questions:
- Is this a known issue or rather a bug?
- Is the descriptor declaration wrong?
- Does this happen to all RAW based fields or just if there is serialized data stored in RAW fields?
Can anyone help? Thanks in advance.
Klaus
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079044#4079044
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079044
More information about the jboss-user
mailing list