tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacek Laskowski" <ja...@laskowski.net.pl>
Subject Re: OpenEJB and Hibernate
Date Tue, 16 Oct 2007 19:57:14 GMT
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

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Mime
View raw message