This is discussed in the other thread Dhanji linked to. The problem
is that it violates the principal of least surprise. I find it much
cleaner knowing that when I interact with Provider<EntityManager> there
is some backing scope. And in all honesty I don't notice much difference
between using Provider<EntityManager>.get() versus EntityManager
directly. Adding get() is hardly the end of the world and it makes you
appreciate that you shouldn't be storing references to the underlying
EntityManager.
Gili
Adam Ruggles wrote:
> I could be wrong but doesn't spring give you a proxy EntityManager,
> which behind the scenes works like your provider?
>
> On Mon, Oct 27, 2008 at 8:00 PM, Dhanji R. Prasanna <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>
>
> On Tue, Oct 28, 2008 at 1:50 PM, Timothy Braje
> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
> On Monday 27 October 2008 20:08:44 Dhanji R. Prasanna wrote:
> > On Tue, Oct 28, 2008 at 1:06 PM, Timothy Braje
> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
>
> <snip>
>
>
>
> Good point, but I remember having to do more work in the
> content of the
> method, dealing with transactional semantics.
>
>
> No, you don't even need the @Transactional annotation (you can use
> Spring's or EJB's or none at all).
>
>
> Also, if I remember correctly,
> you have to inject a Provider<EntityManager> and then a
> emProvider.get()
> rather than just em.<callmethod>.
>
>
> You would have the same problem with Spring, EJB and
> @PersistenceContext. It's just that their tutorials assume you
> aren't using a singleton and ours do (hence, the provider =)
>
> Dhanji.
>
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---