|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.archiviststoolkit.hibernate.HibernateUtil
public class HibernateUtil
Basic Hibernate helper class, handles SessionFactory, Session and Transaction.
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 Summary | |
---|---|
HibernateUtil()
|
Method Summary | |
---|---|
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.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 |
registerInterceptor(org.hibernate.Interceptor interceptor)
Register a Hibernate interceptor with the current thread. |
static void |
rollbackTransaction()
Rollback the database transaction. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HibernateUtil()
Method Detail |
---|
public static org.hibernate.SessionFactory getSessionFactory()
public static org.hibernate.cfg.Configuration getConfiguration()
public static void rebuildSessionFactory() throws InfrastructureException
InfrastructureException
public static void rebuildSessionFactory(org.hibernate.cfg.Configuration cfg) throws InfrastructureException
cfg
-
InfrastructureException
public static org.hibernate.Session getSession() throws InfrastructureException
InfrastructureException
public static void closeSession() throws InfrastructureException
InfrastructureException
public static void beginTransaction() throws InfrastructureException
InfrastructureException
public static void commitTransaction() throws InfrastructureException
InfrastructureException
public static void rollbackTransaction() throws InfrastructureException
InfrastructureException
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().
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |