public class HibernateUtilHis
extends java.lang.Object
Uses a static initializer for the initial SessionFactory creation and holds Session and Transactions in thread local variables. All exceptions are wrapped in an unchecked InfrastructureException.
Constructor and Description |
---|
HibernateUtilHis() |
Modifier and Type | Method and Description |
---|---|
static void |
beginTransaction()
Start a new database transaction.
|
static void |
closeSession()
Closes the Session local to the thread.
|
static void |
commitTransaction()
Commit the database transaction.
|
static org.hibernate.Session |
disconnectSession()
Disconnect and return Session from current Thread.
|
static org.hibernate.cfg.Configuration |
getConfiguration()
Returns the original Hibernate configuration.
|
static org.hibernate.Session |
getSession()
Retrieves the current Session local to the thread.
|
static org.hibernate.SessionFactory |
getSessionFactory()
Returns the SessionFactory used for this static class.
|
static void |
rebuildSessionFactory()
Rebuild the SessionFactory with the static Configuration.
|
static void |
rebuildSessionFactory(org.hibernate.cfg.Configuration cfg)
Rebuild the SessionFactory with the given Hibernate Configuration.
|
static void |
reconnect(org.hibernate.Session session)
Reconnects a Hibernate Session to the current Thread.
|
static void |
registerInterceptor(org.hibernate.Interceptor interceptor)
Register a Hibernate interceptor with the current thread.
|
static void |
rollbackTransaction()
Commit the database transaction.
|
public static org.hibernate.SessionFactory getSessionFactory()
public static org.hibernate.cfg.Configuration getConfiguration()
public static void rebuildSessionFactory() throws OATException
OATException
public static void rebuildSessionFactory(org.hibernate.cfg.Configuration cfg) throws OATException
cfg
- OATException
public static org.hibernate.Session getSession() throws OATException
OATException
public static void closeSession() throws OATException
OATException
public static void beginTransaction() throws OATException
OATException
public static void commitTransaction() throws OATException
OATException
public static void rollbackTransaction() throws OATException
OATException
public static void reconnect(org.hibernate.Session session) throws OATException
session
- The Hibernate Session to be reconnected.OATException
public static org.hibernate.Session disconnectSession() throws OATException
OATException
public static void registerInterceptor(org.hibernate.Interceptor interceptor)
Every Session opened is opened with this interceptor after registration. Has no effect if the current Session of the thread is already open, effective on next close()/getSession().