[jboss-user] [Beginners Corner] - EJB 3 merge vs persist

hebahob do-not-reply at jboss.com
Wed Sep 27 13:48:41 EDT 2006


Hi,

I have a remote client using jndi (InitialContext) to grab remote interfaces of EJBs (I am using EJB3.0, so I am not talking about the home/remote difference, but I am grabbing the interface I have annotated as @Remote).  If this client picks up an EntityManager with a standard persistence context, how should I put changes back to the server after changing the entity?

Currently I use:

  | mgr.merge( changedObject );
  | mgr.persist( changedObject );
  | 

I understand that persist works only if the entity is still in managed state according to the container.  The two areas of confusion for me are:

1.  Does merge do the persist too?  Or does it simply bring the entity back into persistent state, and then I need to persist() as above?

2.  Are all entity beans that are used from session bean stubs on remote clients pulled out of context?  i.e. Do I have to always call merge if I use an entity bean [from a session bean] from a remote client?

Thanks in advance

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

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



More information about the jboss-user mailing list