On Sat, Mar 3, 2012 at 5:20 AM, Owen Berger <[email protected]> wrote:

> In reading about this stuff, I have come across mention of the
> PersistFilter.... Do I HAVE to use that, or is my injection of
> EntityManager or a provider thereof, good enough when combined with an
> @Transactional annotation on a method.
>

If you're managing the EntityManager's lifecycle yourself (ie. calling the
EntityManagerFactory), you must close it yourself. That could be done in a
PersistFilter so you don't have to call it everywhere.

Since an EntityManager must not be shared between threads, put it in
request scope, then use a provider in the PersistFilter to retrieve the
current EntityManager and close it when the request is done. I've never
used Guice-Persist, but it probably handles all this for you.

Moandji

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to