openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig L Russell <Craig.Russ...@Sun.COM>
Subject Re: Injecting EntityManager to a web controller
Date Wed, 06 Jun 2007 15:32:50 GMT

On Jun 6, 2007, at 8:28 AM, David Jencks wrote:

> On Jun 6, 2007, at 5:03 AM, Joshua Jackson wrote:
>> Dear all,
>> If I deploy my webapps to a server that has OpenJPA in it (let's say
>> Geronimo). How do I inject EntityManager to my web controller?
> I'm not sure what your web controller might be.  You can inject an  
> entity manager into a servlet or jsf managed bean using an  
> @PersistenceContext annotation

You can only inject an EM into a servlet if the servlet is single- 
threaded. You need to inject an EMF.

You can inject an EM into a jsf managed bean if it is defined as  
request scope IIUC.


> ; the related annotations for EMF or getting an EM into jndi also  
> work the same as for ejbs.  You can't get an EM injected into a non- 
> managed object that you create yourself, for such an object you  
> would have to look it up in jndi yourself.
> thanks
> david jencks
>> Is it
>> the same way as shown in OpenJPA examples?
>> Thanks in advance
>> -- 
>> Let's create a highly maintainable and efficient code
>> YM!: thejavafreak
>> Blog:

Craig Russell
Architect, Sun Java Enterprise System
408 276-5638
P.S. A good JDO? O, Gasp!

View raw message