Hi!

   I have the following stateful bean:

  | 
  | public class MyStatefulBean implements MyStatefulBeanI,  
SessionSynchronization {
  | 
  |   @PersistenceUnit(unitName = "db")
  |   public EntityManagerFactory factory;
  | 
  |   public MyEntity getObject( int id ) throws Exception {
  |     EntityManager m = factory.createEntityManager();
  |     return m.find(MyEntity.class, id);
  |   }
  | 
  |   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
  |   public MyEntity update( MyEntity newEntity ) throws Exception {
  |     EntityManager m = factory.createEntityManager();
  |     oldEntity e = m.find(MyEntity.class, id);
  | 
  |     e.setAttribute1( newEntity.getAttribute1() );
  |     ...
  |     ...
  |     m.flush();
  |     m.clear();
  |                 m.close();
  |   }
  | 
  |   public void afterCompletion(boolean flag) throws EJBException, 
RemoteException {
  |      if( flag == true ) {
  |     sendJMSMessage()
  |      }
  |    }
  | 
  |    .....
  | 
  | }
  | 
  | 

As far as I understood, after update() it is not guaranteed, that the data is 
in database and commit event already happened. So, as I have the fat clients it 
can be the case, that after update() was called, getObject() still returns the 
old entity.

My question is  - is it guarateed, that after the afterCompletion() method the 
database commit already happened, and it is safe to call getObject() to receive 
the new data?

Thank you,
Konstantin

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002646
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to