permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes One of more persistence context for separate projects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "One of more persistence context for separate projects?" Watch "One of more persistence context for separate projects?" New topic
Author

One of more persistence context for separate projects?

Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
hi,

I develop a pack of applications that use the same database. In order to get all the applications using same entity manager I have created just one persistence.xml file, in my entity beans project. Then I created session beans project and attached entity beans as library. The same I did in seam web application. Now I am bit confused, because entity manager is injected correctly in seam application, but is always null in session beans... I mean, I want to use in web app session bean, I create/inject/annotate (@In,@EJB) and all the time entity manager in session bean is null...

All the tutorials are so simple, just saying how to work inside one project... Could anyone help me with this one?
Om Tejas
Greenhorn

Joined: Dec 02, 2009
Posts: 27
Try @PersistenceContext annotation. This annotation will inject EntityManager in your session ejb.
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
Srivastava Gaurav wrote:Try @PersistenceContext annotation. This annotation will inject EntityManager in your session ejb.


unfortunately entity manager is always null when I try to use session bean in my web application :/ And for sure bean can find persistence unit as deploys without problems. I think I instatate bean in wrong way in my web application (seam), but already tried without luck @In, @EJB or straight with constructing as POJO. Always entity manager is null (and I use @PersistenceContext annotation).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: One of more persistence context for separate projects?
 
Similar Threads
Bean Packaging
How to correctly instate SLSB from another archive?
session bean or entity bean?
EJB lookup and Jboss SEAM
Seam Vs Spring