• Post Reply Bookmark Topic Watch Topic
  • New Topic

Recommended way of getting entity manager from pojo class

 
tovi sofer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In our application we have the need or retrieving entity manager from 'pojo' classes.
More specifically we have singleton classes which act as 'data' repositories and are accessed from both servlets and ejb.
I'm aware that the repositories classes might be problematic, but in the current stage we can't perform significant change in application structure so I am looking for a 'fast' solution as possible.

The best way will be to lookup entityt manager in JNDI, but as I undestand this feature is not avaialabe in weblogic.

I understand that the preffered way for getting entity manager in such situation is by using @PersistenceUnit annotion on the calling location and lookup entityManager by that name in the pojo. This is however problematic for us since since we access the repositories from variouse locations (many different classes).

Possible additional solutions we thought of:
- creating an 'entity manager factory' locator ejb. This is an ejb with no transaction attribute, which has one method getEntityManagerFactory. It injects entityManagerFactory and returns it. This is the fastest soltion to implement. Is this a valid one?
- using application managed entity manager in such situations. We have a problem doing so now because the creation seems to fail for variouse reasons.

What is the recommended way?

Thanks.
 
tovi sofer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I wanted to ask specifiaclly on the solution which is the most similiar I think to searching entityManagerFactory in JNDI:

- creating an 'entity manager factory' locator ejb. This is an ejb with no transaction attribute, which has one method getEntityManagerFactory. It injects entityManagerFactory and returns it.

Is this a valid solution to use?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!