struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Burton Rhodes <>
Subject [S2] Struts 2 + Spring 2 + JPA example uses @PersistenceContext - is this a "bad thing"??
Date Wed, 18 Mar 2009 17:30:28 GMT
I set up the example for "Struts 2 + Spring 2 + JPA + AJAX" using the
OpenEntityManagerInViewFilter from the Struts website and all works
well. (
 It appears this example uses the @PersistenceContext annotation to
inject the EntityManger into each Service/Dao class...

Then I read this blog about how you SHOULD NOT use @PersistenceContext
annotation in a webapp becasue of thread safety unless you implement a

Now I am confused...  Should I instead use @PersistenceUnit to inject
the EntityManagerFactor into each Dao object?  And if so, won't this
affect the OpenEntityManagerInViewFilter and cause Lazy exceptions?
Can someone shead some light on this for me or am I not understanding
this correctly?

Apologies in advance if this is a bit off Struts topic...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message