1 Reply Latest reply on Aug 25, 2007 11:10 AM by srikap2007

    Flushing CMP 2.0 EntityBean updates before end of transactio

    reddy_123

      I am using CMP 2.0 Entity Beans in JBoss v3.2.6

      I am calling EntityBean from within a Stateless Session Bean method.
      The stateless Session Bean method has transaction attribute set to TX_REQUIRED.

      In the Stateless Session Bean method, I am doing a JDBC read after the
      entity bean update, but the JDBC read is not picking up the updates done
      by entity bean.

      Is there any method available in the J2EE container in JBoss which will allow me to flush the entitybean updates, so that the subsequent JDBC read will pick up these updates.

      I have seen that if I call any EntityBean finder (not necessarily the one that I updated) before doing a JDBC read, it seems to be doing the trick.

      But I am just wondering if there is some API in JBoss container, which is allow me to do a flush of pending updates before the end of the transaction.

      Thanks
      Ram

        • 1. Re: Flushing CMP 2.0 EntityBean updates before end of transa
          srikap2007

          Hi Ram,
          Entity Bean is in memory, so you are seeing your updates. And JDBC is reading from database so you are not seeing your updates. EJBFind is returning reference to the bean in memory. Anyway, if you want to see the results from session bean, then you should force entity bean (its like cache/buffer) to commit. That you can do by calling entity bean method with in a transaction (thats the only way ejbStore is guaranteed to call).

          Or you can implement SessionSynchronization interface in your sessionBean. Then you can listen to Beforecommit event. Thats a different approach but more right approach to achieve what you are trying to do.