tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Vysny <...@whitestein.com>
Subject Re: OpenEJB and Hibernate
Date Wed, 17 Oct 2007 07:51:38 GMT

On Tue, 2007-10-16 at 21:57 +0200, Jacek Laskowski wrote:
> On 10/16/07, Martin Vysny <mvy@whitestein.com> wrote:
> 
> > Okay, it's java:comp/TransactionManager from within a bean, or
> > java:openejb/TransactionManager from outside a bean ;) We are using
> > Hibernate via the JPA interface as follows:
> >
> > package com.whitestein.fe.impl.config;
> >
> > import org.hibernate.transaction.JNDITransactionManagerLookup;
> >
> > /**
> >  * Hibernate Transaction manager lookup strategy for OpenEJB.
> >  *
> >  * @author mvy
> >  */
> > public class OpenEJBTransactionManagerLookup extends
> >                 JNDITransactionManagerLookup {
> >
> >         @Override
> >         protected String getName() {
> >                 return "java:comp/TransactionManager"; //$NON-NLS-1$
> >         }
> >
> >         public String getUserTransactionName() {
> >                 return "java:comp/UserTransaction"; //$NON-NLS-1$
> >         }
> >
> > }
> >
> >
> > properties.put(Environment.DIALECT, dbDialect);
> > properties.put(Environment.TRANSACTION_MANAGER_STRATEGY,
> > OpenEJBTransactionManagerLookup.class.getName());
> > properties.put(Environment.TRANSACTION_STRATEGY,
> > CMTTransactionFactory.class.getName());
> > properties.put(Environment.JNDI_CLASS,
> > "org.apache.openejb.client.LocalInitialContextFactory");
> > entityManagerFactory = Persistence.createEntityManagerFactory(
> > persistenceUnitName, properties);
> >
> > This way, Hibernate joins the container transactions.
> 
> Awesome. I wouldn't imagine such stuff is possible in/with OpenEJB.
> Even after so long with openejb I can learn new stuff. It'd be great
> if you could share the app or better yet write a doc how to work with
> hibernate and openejb together. Would you mind? ;-)
> 
> Jacek
> 

Sure, I'll try to prepare a sample project based on OpenEJB example
projects. It will take time though - please be patient ;)
Martin


Mime
View raw message