2009/3/19 David Blevins <david.blev...@visi.com>:
>
> On Mar 18, 2009, at 8:40 AM, Olivier THIERRY wrote:
>
>> Hi,
>>
>> I try to configure a Seam-managed persistence context with Open EJB 3.0.
>> To achieve this, I need to get entity manager factory using its JNDI name.
>>
>> For example, for JBoss, it is something like this :
>>
>> <property name="jboss.entity.manager.factory.jndi.name"
>> value="java:/EntityManagerFactories/bookingData"/>
>>
>> But I can't find the equivalent for Open EJB. So what is the JNDI name
>> for OpenEJB entity manager factory ?
>
> In the current releases there's no global JNDI name for EntityManagerFactory
> instances.  In the trunk version (3.1.1) there is work on that might help.
>
> In the meantime, do you know if Seam can lookup from an EJB's or Servlet's
> java:comp namespace?  If that works, you could add an @PersistenceUnit ref
> (or equivalent xml) somewhere.
>
> -David
>
>

Thanks David,

One more time you were right ! I found a way to make it work and it
uses @PersistenceUnit as you suggested.

I created the following Seam component that is used as entity manager factory :

@Stateless
@Name("entityManagerFactory")
public class EntityManagerFactoryHackBean implements
EntityManagerFactoryHackLocal {
        
        @PersistenceUnit(name="t4Seam")
        EntityManagerFactory entityManagerFactory;
        
        @Unwrap
        public EntityManagerFactory getEntityMangagerFactory()
        {
                return entityManagerFactory;
        }

}

And I configured Seam this way in components.xml :

    <persistence:managed-persistence-context
        name="emanager"
                auto-create="true"
                entity-manager-factory="#{entityManagerFactory}" />

This way Seam creates a "emanager" Seam component with EntityManager
type and put it in conversation scope, so that it can be retrieved the
following way in all Seam components running in the conversation :

    @org.jboss.seam.annotations.In
    protected javax.persistence.EntityManager emanager;

So it looks OK with Seam managed persistence context now.

But now I have some problems with Seam managed transactions. Anyway I
am note sure yet if it's a problem with OpenEJB or Seam.

Have a nice week-end

Olivier

Reply via email to