[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Re: Hibernate StatisticsService MBean doesnt work with Entit
jaikiran
do-not-reply at jboss.com
Thu May 15 03:37:52 EDT 2008
The EntityManager has a getDelegate API: http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#getDelegate()
You can probably do this:
| @PersistenceContext
| EntityManager em;
|
| public void myMethod() {
|
| //get the underlying Hibernate session
| org.hibernate.Session sess = (org.hibernate.Session) em.getDelegate();
|
| //now get the session factory from the hibernate session
| SessionFactory sf = sess.getSessionFactory();
| }
P.S: I don't know why JPA doesn't provide a similar getDelegate() method on the EntityManagerFactory to access the provider specific entitymanagerfactory.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4150946#4150946
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4150946
More information about the jboss-user
mailing list