Ok, but I only call my get on my provider inside a method with tx 
annotation.
This limit of guice made me switch back to spring :/

Op woensdag 7 mei 2014 16:39:20 UTC+2 schreef scl:
>
> Guice perstist has a feature which is rather unusual und causes some 
> problems. I think you might just be hitting it.
>
> When you request an entity manager outside of a unit of work guice persist 
> will implicitly start the unit of work for you. Unfortunately the 
> isActive() on UnitOfWork is package private. And you cannot test if a unit 
> of work is active.
>
> There are two ways to explicitly start and end a unit of work. You can use 
> the UnitOfWork and the methods begin() and end(). Also the @Transactional 
> annotation starts a unit of work. @Transactional will also end the unit of 
> work if and only if it started it.
>
> It is best practice to only obtain an entity manager within a 
> @Transactional method.
>
> > Am 07.05.2014 14:33 schrieb Jelle Victoor <[email protected]<javascript:>
> >:
> >>
> >> I have a rather large problem with my guice entitymanager.
> >> I followed the guide supplied on the guicePersist pages but I still 
> seem to be having issues. I don't use the open session in view filter (and 
> I'm not planning to use this)
> >> The problem is guice is reusing my session context in my threads. So 
> when I call a method, annotated with the @Transactional attribute, my 
> entity manager is reused when I start hitting the same threads on my 
> webserver (rest endpoints).
> >> Because I don't want to use Provider<EntityManager>.get each time, I 
> have wrapped this in a proxy with delegate methods. These delegate methods 
> call provider.get.method(). This proxy is a eagerSingleton, injected over 
> my whole application. This mean the provider each time should start a new 
> entityManager when in the same jpalocaltxninterceptor.
> >> I can't believe I'm the only person who is trying this, so I suppose I 
> must be doing something wrong, but I cant figure out what exactly.
> >> I have created a stackoverflow thread, but then I didn't really know 
> what the exact problem was 
> http://stackoverflow.com/questions/23503484/jpa2-reuses-entitymanager-with-guice
> >>
> >> -- 
> >> You received this message because you are subscribed to the Google 
> Groups "google-guice" group.
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <javascript:>.
> >> To post to this group, send email to 
> >> [email protected]<javascript:>
> .
> >> Visit this group at http://groups.google.com/group/google-guice.
> >> For more options, visit https://groups.google.com/d/optout.
>  

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to