[jboss-user] [EJB 3.0] - Intercepting EntityManagerFactory creation

davesb do-not-reply at jboss.com
Mon Dec 3 07:41:02 EST 2007


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?!

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109822#4109822

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109822



More information about the jboss-user mailing list