mirror of
https://github.com/sismics/docs.git
synced 2024-09-20 19:00:08 +02:00
28 lines
665 B
Java
28 lines
665 B
Java
package com.sismics.util.jpa;
|
|
|
|
import org.hibernate.Session;
|
|
import org.hibernate.SessionFactory;
|
|
import org.hibernate.ejb.HibernateEntityManagerFactory;
|
|
|
|
/**
|
|
* Hibernate session utilities.
|
|
*
|
|
* @author jtremeaux
|
|
*/
|
|
public final class SessionUtil {
|
|
/**
|
|
* Private constructor.
|
|
*/
|
|
private SessionUtil() {
|
|
}
|
|
|
|
/**
|
|
* Returns an instance of the current session.
|
|
*
|
|
* @return Instance of the current session
|
|
*/
|
|
public static Session getCurrentSession() {
|
|
SessionFactory sessionFactory = ((HibernateEntityManagerFactory) EMF.get()).getSessionFactory();
|
|
return sessionFactory.getCurrentSession();
|
|
}
|
|
} |