Passivation
amontobin Feb 25, 2010 4:07 PMHi Seam Users,
I've read this chapter EJB Passivation and the ManagedEntityInterceptor
As I understand it, it seems that seam is capable of passivate SMPC (EntityManager with @In) and
reattach all instances loaded at activation.
It works fine if the persistent object is directly a field of the stateful bean but not
if i use a wrapper object for it.
Is it a bug ? Or do i have to do the work manually ?
Here is my example :
When i first click on the submit button, the two needs are loaded and binded to current sesssion (I use Hibernate).
I wait passivation.
On the second click, activation takes place and the result is that one need is rebinded to the current session but not the one in the wrapper (wrapper is serializable)
@Stateful @Name("testconversation1") @AutoCreate @Scope(ScopeType.CONVERSATION) public class TestConversation1Controller implements TestConversation1ControllerInterface { private static Logger logger = Logger.getLogger(TestConversation1Controller.class); @In EntityManager entityManager; private NeedImpl need; private Test1Wrapper wrapper; public String submit() { logger.info("submit"); Seams.printConversationStackTrace(); NeedManagerImpl manager = new NeedManagerImpl(); manager.setEntityManager(entityManager); if (wrapper == null) { wrapper = new Test1Wrapper(); } if (wrapper.getNeed() == null) { wrapper.setNeed(manager.getById(1)); } if (need == null) { need = manager.getById(2); } logger.info("Object :" + entityManager.contains(need)); logger.info("Wrapper Object :" +entityManager.contains(wrapper.getNeed())); return null; } @Remove public void destroy() { } @PostConstruct public void postConstruct() { logger.info("postConstruct"); } @PreDestroy public void preDestroy() { logger.info("preDestroy"); } @PrePassivate public void prePassivate() { logger.info("prePassivate"); } @PostActivate public void preActivate() { logger.info("preActivate"); } }
Any help would be appreciated,
Thanks,
Sebastien Boutte