Hi HuiSheng,
Thanks again for your help!
if you wish to get the hibernate session factory from the EntityManagerFactory using Java code, you would do:
public static SessionFactory getSessionFactory(EntityManagerFactory emf) {
if (emf == null) {
return null;
}
HibernateEntityManagerFactory hemf = (HibernateEntityManagerFactory) emf;
return hemf.getSessionFactory();
}
However, in Spring it is easy to retrieve a sessionFactory from the underlying entitymanagerfactory like so:
<property name="persistenceUnitPostProcessors">
<bean>
<property name="jtaDataSource" ref="dataSource" />
</bean>
</property>
<property name="loadTimeWeaver">
<bean />
</property>
</bean>
<bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory" />
The sesssion factory returned by this method will be of type HibernateSessionFactory.
Does this help?