0 Replies Latest reply on Dec 3, 2007 7:40 AM by davesb

    Intercepting EntityManagerFactory creation

    davesb

      I'm using JPA (Hibernate)/Seam/JBoss AS and I have an unusual (perhaps) problem to solve.

      The application consists of a bunch of normal JPA mapped entities PLUS a number of "unknown-at-compile-time" dynamic entities. These are defined in a separate configuration and can change at runtime. I'm looking at using Hibernate's Map-based session for the dynamic entities, and this seems to work really well.

      If I use Hibernate directly and create my own HibernateSessionFactory (like in a Java SE environment) I can easily intercept the factory creation and add in the dynamic entities (using the configuration.addResource() or similar). However, I'd like to keep the convenience of standard EJB annotations and inject the EntityManager into my EJBs using @PersistenceContext.

      Is there a neat way of intercepting the EntityManagerFactory creation? Can I get into the Hibernate configuration (to change it) through the container provided EntityManagerFactory? Is there a better way of doing this?!