I need a specific feature of hibernate that is StatelessSession and for that I need Hibernate\'s SessionFactory. The problem is I only have the entityManagerFactory. How can I g
Option 1 through EntityManagerFactory
If you use Hibernate >= 4.3 and JPA 2.1 you can accces the SessionFactory from a EntityManagerFactory through .
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
Option 2 through EntityManager
If you use Hibernate >= 4.3 and JPA >= 2.0 then you can accces the Session from the EntityManager through . From the Session you can obtain the SessionFactory.
Session session = entityManager.unwrap(Session.class);
SessionFactory sessionFactory = session.getSessionFactory();