Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Last active January 3, 2016 03:09
Show Gist options
  • Save yanhua365/8400661 to your computer and use it in GitHub Desktop.
Save yanhua365/8400661 to your computer and use it in GitHub Desktop.
从JPA的EMF中得到Hibernate的SessionFactory,参考:http://www.jroller.com/RickHigh/entry/getting_sessionfactory_from_entitymanagerfactory_in
public static SessionFactory getSessionFactory(EntityManagerFactory hemf) {
return ((HibernateEntityManagerFactory)hemf).getSessionFactory();
}
//得到hibernate的session
//http://stackoverflow.com/questions/4335570/accessing-hibernate-session-from-ejb-using-entitymanager
HibernateEntityManager hem = em.unwrap(HibernateEntityManager.class);
Session session = hem.getSession();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment