openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hans J. Prueller" <hans.pruel...@gmx.net>
Subject AW: Howto integrate JPA within EJB2.1 session beans? [architecture]
Date Wed, 21 Feb 2007 15:31:25 GMT
Kevin,

if you missed previous discussions on the list: I am using OpenJPA within
a Java2EE 1.4 container - therefore I cannot use container injection
unfortunately!

hans

> -----Urspr√ľngliche Nachricht-----
> Von: Kevin Sutter [mailto:kwsutter@gmail.com]
> Gesendet: Mittwoch, 21. Februar 2007 12:58
> An: open-jpa-dev@incubator.apache.org
> Betreff: Re: Howto integrate JPA within EJB2.1 session beans?
> [architecture]
> 
> Hans,
> Instead of managing the lifecycle of the EntityManagerFactory and
> EntityManager yourself, why not use injection of the EM via
> @PersistenceContext?  There are several examples of this usage in the JPA
> spec and the OpenJPA documentation.
> 
> Kevin
> 
> On 2/21/07, Hans Prueller <hans.prueller@gmx.net> wrote:
> >
> > Hi together,
> >
> > I'm sorry for bothering you with numerous basic questions regarding
> > OpenJPA and its usage but I have to migrate existing CMP EJBs to migrate
> > within short time to OpenJPA as we're having stability issues with the
> > current CMP engine.
> >
> > One last question I'd like to ask is regarding the recommended
> > architecture of using OpenJPA within EJB2.1 Stateless sessino beans:
> >
> > I need to work with persistence i.e. the EntityManager throughout all
> the
> > session beans methods so my idea is to:
> >
> > - create a EntityManagerFactory in the ejbCreate() method of the SLSB
> > - and also create the EntityManager itself in the ejbCreeate() method
> and
> > store it as a member variable of the SLSB
> > - this would allow easy access within the SB's methods by just using the
> > already initialized entity manager varialbe em.createNamedQuery() ..
> etc.
> > etc.
> > - clean up should be performed in the ejbRemove() method of the SLSB
> >
> > I think doing so will allow migratino to openJPA with less work than
> doing
> > the whole lookup procedure in every method separately.
> >
> > what do you think? are there any pitfalls i've overlooked?
> >
> > thank you for your ideas!
> >
> > regards
> > Hans
> > --
> > "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
> > Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out
> >


Mime
View raw message