-
1. Re: manual flushMode in conversation need in session
idyoshin Mar 2, 2010 12:08 AM (in response to nimo22)the only problem in session bean is to get correct entityManager - that could be achieved by calling Component.getInstance("entityManager", true); Or Another way - to move this enetityManager logic to the event, or even Stateless scope, and extend from EntityController superclass.
If you haven't overrided the default seam parameters - the default flushmode is Manual ;) so you don't have to do something explicit, except than mark your method as @Transactional.
Kind regards,
Ilya Dyoshin
-
2. Re: manual flushMode in conversation need in session
nimo22 Mar 2, 2010 8:27 AM (in response to nimo22)I call my entityManager within a stateless EJB!
@Stateless @Name("myEJB") public class MyEJB[ { public User getUser{ return entityManager.find(..); } }
and getUser is invoked in my ClientBean, which is conversation scoped:
@Name("myBean") @Scope(SESSION) public class MyBean{ @In(create=true) MyEJBLocal myEjb; // FlushModeType.MANUAL // is this the only solution? public void do(){ entityManager.setFlushMode(javax.persistence.FlushModeType.COMMIT); User u = myEjb.getUser(..); ... // entityManager.flush(); } }
So what do I have to do, when I want to use a Session Bean instead of a Conversation Bean and the Session Bean should have something like
flushMode = FlushModeType.MANUAL
???
-
3. Re: manual flushMode in conversation need in session
idyoshin Mar 2, 2010 2:48 PM (in response to nimo22)you can define the method
getEntityManager() { return (EnityManager )Contexts.getInstance("entityManager", true); }
and anytime you call this method inside of the session-scoped bean the entityManager would be the most relevant for the current user activity.
Kind regards,
Ilya Dyoshin