@TransactionScoped beans get destroyed after finishing the outermost method
(in the callstack) annotated (in-/directly) with @org.apache.deltaspike.jpa.
api.transaction.Transactional.

in case you are using ejbs and CMT, the container already manages the scope
for you (and you just get a proxy-instance anyway - which can be exposed as
dependent bean).
-> it really depends on the mode you are using.

regards,
gerhard



2018-02-13 12:31 GMT+01:00 Luís Alves <luisalve...@gmail.com>:

> There you use the @RequestScoped....and you present @TransactionScoped,
> which seems exactly what I want but not sure what happens when TX is marked
> as NEVER or SUPPORTS (and none is oppened).
>
> On Tue, Feb 13, 2018 at 11:15 AM, Gerhard Petracek <gpetra...@apache.org>
> wrote:
>
> > hi luis,
> >
> > please have a look at [1].
> >
> > regards,
> > gerhard
> >
> > [1] http://deltaspike.apache.org/documentation/jpa.html#Basicusage
> >
> >
> >
> > 2018-02-13 12:11 GMT+01:00 Luís Alves <luisalve...@gmail.com>:
> >
> > > Well...I have REST services...so I think RequestScoped EM would be ok.
> > >
> > > On Tue, Feb 13, 2018 at 10:55 AM, Thomas Andraschko <
> > > andraschko.tho...@gmail.com> wrote:
> > >
> > > > If an AppScoped EntityManager is the right thing for you, yes.
> > > > In my webapplication i mostly use RequestScoped EMs.
> > > >
> > > > 2018-02-13 11:39 GMT+01:00 Luís Alves <luisalve...@gmail.com>:
> > > >
> > > > > "An instance of a dependent bean is never shared between *different
> > > > clients
> > > > > *or different injection points."
> > > > > "Beans with scope @Dependent don’t need a proxy object. The client
> > > holds
> > > > a
> > > > > direct reference to its instance."
> > > > >
> > > > > so...I think I should be OK.
> > > > >
> > > > > On Tue, Feb 13, 2018 at 10:29 AM, Luís Alves <
> luisalve...@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > So my Service layer is @ApplicationScoped.
> > > > > > Since Inject the @Repository into my service layer and is
> > @Dependent
> > > it
> > > > > > will be an @ApplicationScoped. I'm producing my EM like:
> > > > > >
> > > > > > @ApplicationScoped
> > > > > > public class EntityManagerProducerImpl implements
> > > EntityManagerProducer
> > > > > > {
> > > > > >
> > > > > >     @PersistenceContext(unitName = "unit")
> > > > > >     private EntityManager entityManager;
> > > > > >
> > > > > >
> > > > > >     @Override
> > > > > >     @Produces
> > > > > >     @Default
> > > > > >     public EntityManager get()
> > > > > >     {
> > > > > >         return entityManager;
> > > > > >     }
> > > > > > }
> > > > > >
> > > > > > So...will it work properly? or do I have to mark my EM as
> > > > @RequestScoped?
> > > > > >
> > > > > > LA
> > > > > >
> > > > > >
> > > > > >
> > > > > > On Tue, Feb 13, 2018 at 10:24 AM, Thomas Andraschko <
> > > > > > andraschko.tho...@gmail.com> wrote:
> > > > > >
> > > > > >> Hi,
> > > > > >>
> > > > > >> the default scope is @Dependent but i suggest everyone to use
> > > > > >> @ApplicationScoped.
> > > > > >> The EM will be proxied if you use a NormalScope like
> > @RequestScoped,
> > > > > ....
> > > > > >>
> > > > > >> Regards,
> > > > > >> Thomas
> > > > > >>
> > > > > >> 2018-02-13 10:54 GMT+01:00 Luís Alves <luisalve...@gmail.com>:
> > > > > >>
> > > > > >> > Hi,
> > > > > >> >
> > > > > >> > What is the scope of @Repository? Do you use a similar
> approach
> > of
> > > > > >> Spring?
> > > > > >> > @Singleton and proxy the EM?
> > > > > >> >
> > > > > >> > Regards,
> > > > > >> > LA
> > > > > >> >
> > > > > >>
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Reply via email to