Reputation: 1482
Is is possible to create hibernate SessionFactory
object from persistence.xml
.
Usually we create EntityManagerFactory
using persistence.xml
, I would like to know if SessionFactory
could be created.
I googled it but did not find any useful resource.
Upvotes: 2
Views: 2417
Reputation: 2785
If you are using a recent version of Hibernate that supports JPA 2.1, you can use the unwrap
method on the EntityManagerFactory
: https://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/EntityManagerFactory.html#unwrap(java.lang.Class)
If what you are really after is a Hibernate Session
object, you can get that from the EntityManager
object using the getDelegate
method.
Upvotes: 2