tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: EntityManager into controller viewscoped
Date Sun, 12 Feb 2017 14:22:13 GMT
Hi

2017-02-12 14:38 GMT+01:00 mauro2java2011 <mauro2java2011@gmail.com>:

> Hi all.
>
> I would use a requestscoped entitymanager into a viewaccesscoped
> controller.
>
> So i ask:
>
> The injected em requestscoped into controller viewscoped is a new em for
> each request or  is all times the same into viewscoped  controller?
>
> I know that the entity manager is not serializable.
>
> It is but it is not reliable in most cases


> So if the em is  requestscoped i resolve the problem with tge serialization
> of the em into viewaccesscoped cobtroller?
>
> I have to configure some thing for use jta into cdi injected em ?
>
> Jta scope = transaction so not sure it matches


> Into the class where i declare the method productor i have to use the
>
> @PersistenceContext (unitNane="namePU")
> private EntityManager em;
>
> @Produces
> @RequestScoped
>
> public EntityManager getEntityManager (){
> return this.em;
>
> }
>
> Or i have to use the EntityManagerFactory with
>
> @PersistenceUnit (name="namePu")
>
> private EntityManagerFactory emf;
>
> public getEntityManager (){
> return emf.createEntityManager;
>
> }
>
> public void closeEm (@Disposes EntityManager em){
>
> em.close ();
>
> }
>
>
this works for resource_local EM


reading your mail it looks you just want a command pattern with a final jta
transaction instead of immediate EM actions


> Tank you very much .
>
> Mauro
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/EntityManager-into-controller-viewscoped-tp4681054.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message