[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - EntiyBean is reloaded during transaction with commit-option

smeier do-not-reply at jboss.com
Fri Apr 27 09:11:27 EDT 2007


Hi all,

I recently changed the commit-option for my entiy-beans from A to D with a refresh-period of 10 seconds. Since then I sometimes experience unreproducable errors in data import service (which essentially reads in some files, performs some checks and then writes the data to persistent storage via EntityBeans). After some investigation I was able to create a test case which resembles the error I'm experiencing (at least I think so).
My test goes like this: in a stateless session bean (with @ejb.transaction type="Required") 
- I load an entity bean (findByPrimaryKey)
- modify one of it's fields (set from "oldvalue" to "newvalue")
- print the value of the previously modified field (it says "newvalue")
- sleep 20 seconds
- print the value of the previously modified field (it now says "oldvalue")
- check the value in the database after the transaction completes (it says "newvalue")

So in the end the new value has successfully been written to the database but since the field in the entity bean has been reset, computations that are using the value of this field in the remainder of the transaction might yield to wrong results.

Now here's my question: Is this the expected behaviour? As you might guess I don't think it is. http://wiki.jboss.org/wiki/Wiki.jsp?page=CMPFlushAgeOutStoreNotFlushed says the following about cache invalidation:
 
anonymous wrote : if the instance is in use, it will be removed and passivated at the end of the transaction it is used in
  | 

Any help is greatly appreciated.

Best regards,
Stefan

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4041391#4041391

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4041391



More information about the jboss-user mailing list