Last active
January 3, 2016 03:09
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static SessionFactory getSessionFactory(EntityManagerFactory hemf) { | |
return ((HibernateEntityManagerFactory)hemf).getSessionFactory(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//得到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