[jboss-user] [EJB/JBoss] - Some entity instances are not updated after merge

galo.navarro do-not-reply at jboss.com
Wed Nov 15 09:43:43 EST 2006

I have the following scenario:

Users get into a web page, a HTTP session is created and depending on their properties they get a collecition of Entity Beans, details are displayed in the browser and they can do some updates to them. These updates are executed via a Servlet, that uses a Stateless SB to perform the operations. I.e., calling the updateFlag method below.

When these updates happen everything seems alright, db is updated, I can find the entity with the entity manager and it retrieves the correct values etc. But if I look at the entity instance in the user session's collection its values are out of date. 

As far as I've understood, every time merge is called on an entity bean, the entity manager should take care of updating all the instances of it, so all the collections that have an instance of the entity should reflect the update. This doesn't happen even for the user that executed the update.

Am I doing something wrong? 

This is the code that performs the action in the servlet

  |    NOC n = accessBean.findNOC(id);
  |    accessBean.updateFlag(n);


  | 	@TransactionAttribute (TransactionAttributeType.REQUIRED)
  | 	public NOC findNOC(Integer id) {
  | 		return em.find(NOC.class, id);		
  |         }
  | 	@TransactionAttribute(TransactionAttributeType.REQUIRED)
  | 	public NOC updateFlag(NOC noc) {
  | 		noc.setFlagged(!noc.getFlagged());
  | 		return saveNOC(noc);
  | 	}
  | 	@TransactionAttribute (TransactionAttributeType.REQUIRED)
  | 	public NOC saveNOC(NOC noc) {
  | 		noc.setDtTmStp(new Date());
  | 		return em.merge(noc);
  | 	}


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

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

More information about the jboss-user mailing list