Dear all,

I am actually trying to switch from "raw" Hibernate to JPA.

I have the typical "keep the same entitymanager" during a scenario problem. IMHO, merging huge collections of entities is a nightmare that is not worth the cost when you deal with applications with a lot of business logic but few users and a low load. I fully endorse the "entitymanager per request" pattern for application having high trafic, and so need to be stateless, replicated, etc. but it does not appear to me to be the magic solution to all problems.

With hibernate, I historically solved it with the "open session in view" pattern. It is ugly when evaluated according to actual standards, but it works.

    https://developer.jboss.org/wiki/OpenSessionInView

When I tried to find the equivalent for JPA, I basically found

@PersistenceContext(type=PersistenceContextType.EXTENDED)

...which could be a fit if I was using container managed datasources

When digging the Hibernate 4.3.8 jpa implementation, I noticed that when I use 
application managed EntityManager-s, they are all created with 
PersistenceContextType.EXTENDED, and that this attribute is finally passed to :
AbstractEntityManagerImpl base class constructor :

        protected AbstractEntityManagerImpl(
                        EntityManagerFactoryImpl entityManagerFactory,
                        PersistenceContextType type,  // TODO:  remove as no 
longer used
                        SynchronizationType synchronizationType,

and is just ignored. :-)

On this blog (I like good authors ;-) ) 
https://struberg.wordpress.com/2012/04/25/is-there-a-way-to-fix-the-jpa-entitymanager/
 , I found mention of Avaje, which could be a fit if it was more of a standard.

I also fond on the net references to CODI, MyFaces Orchestra and Seam solutions to this 
problem. Most of the type it was also indicated that Deltaspike is "the way to 
go". An affirmation that is clearly also mine in general.
However, I did not find a ready-to-use solution in the doc

   
http://deltaspike.apache.org/documentation/jpa.html#_extended_persistence_contexts

I was a bit surprised, as some people stated that Seam code was to be merged in 
Deltaspike not to find a turn key solution.

Did I miss / misunderstood something ?

This is not a blocking problem to me. I can just use plain hibernate or 
unwrapped jpa/hibernate sessions and it will work... But I would like to 
understand. :-)

Thanks in advance,

Ludovic


|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|

Reply via email to