Hello,

Does DS provides a requestScopes em ?

I tried to to something like https://cwiki.apache.org/EXTCDI/jpa-usage.html, 
but I had an error (don't remember which one, I think it was because em wasn't 
associated with current tx)

For the moment, I'm using softwaremill EntityManagerTxEnlistDecorator 
(https://github.com/softwaremill/softwaremill-common/tree/master/softwaremill-cdi/src/main/java/pl/softwaremill/common/cdi/persistence
and doing something like (I'm doing it from memory so, there can be some 
errors) :

public class EntityManagerProducer {
   @PersistenceUnit(name="pu")
   private EntityManagerFactory emf;

    @Produces @RequestScoped
    public EntityManager getEntityManager() {
        return new EntityManagerTxEnlistDecorator (emf.createEntityManager());
    }

    public void close(@Disposes EntityManager em) {
        em.close();
    }
}

Not sure if it deserves a special classe in DS (perhaps at least 
softwaremill EntityManagerTxEnlistDecorator   ?)

Thanks

Reply via email to