[ 
https://issues.apache.org/jira/browse/OWB-626?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13133976#comment-13133976
 ] 

Mark Struberg commented on OWB-626:
-----------------------------------

The extended persistence context is imo pretty questionable. It is basically 
the EntityManager-per-Session approach and you can find a lot of documentation 
on the internet why this is broken by design.
It really only works with the special assumption that you are using Hibernate 
(which is not used in WebSphere) and don't use clustering at all. The reason is 
that per the JPA spec any EntityManager is *NOT* Serializable. Thus you cannot 
put it into a bean with a passivating scope (especially @SessionScoped, 
@ConversationScoped). 

Hibernates EntityManager is Serializable, but only under _very_ special 
conditions! You also will lose any current state of all your entities and 
things like 'select for update' and EntityManager.lock() will lead to blowup 
your hibernate session.
Btw, clustering has been broken in Seam2 also...

The are 3 ways to get clustering support in JavaEE  
* use EJBs transaction handling. But be aware that you need to load all the 
data in your EJBs, otherwise you might get a LazyInitialisationException

* use @RequestScoped EntityManagers and a @Transactional interceptor (from 
Seam3 or CODI) This will allow lazy loading in your JSF, Wicket, etc views, but 
also has the downside that you need to care about parallel request. E.g. it is 
not possible to  stuff such entities into a shared cache because that might 
lead to concurrency Exceptions (btw you as well have the same restriction in 
any pattern which use EM-per-Session)

* use @TransactionalScoped EntityManagers and @Transactional from CODI. This 
basically gives you almost the same behaviour as EJB auto-transactions (but 
currently without distributed transactions), so you need to take care of 
LazyInitialisationExceptions. This is really similar to having the old DAO 
pattern, but without having to write DAO objects ;)
 

                
> Conversation Scope isn't accessible after RENDER_RESPONSE phase
> ---------------------------------------------------------------
>
>                 Key: OWB-626
>                 URL: https://issues.apache.org/jira/browse/OWB-626
>             Project: OpenWebBeans
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.1.1
>            Reporter: Thierry Robin
>            Assignee: Mark Struberg
>             Fix For: 1.1.3
>
>
> In CDI 1.0, the Conversation Scope is normaly accessible from after 
> RESTORE_VIEW phase in JSF, to the end of the Response.
> But It's not the case during the after phase(RENDER_RESPONSE) of any 
> PhaseListener implementation.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to