1 Reply Latest reply on Apr 27, 2007 9:13 AM by Stefan Meier

    EntiyBean is reloaded during transaction with commit-option

    Stefan Meier Newbie

      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:

      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