Classes | |
class | HibernateUtilException |
Public Member Functions | |
void | setConfiguration (Properties extraProperties) |
void | setConfiguration (Configuration config) |
SessionFactory | getSessionFactory () |
Configuration | getConfiguration () |
void | rebuildSessionFactory () throws HibernateUtilException |
void | rebuildSessionFactory (Configuration cfg) throws HibernateUtilException |
Session | getSession () throws HibernateUtilException |
void | closeSession () throws HibernateUtilException |
void | beginTransaction () throws HibernateUtilException |
void | commitTransaction () throws HibernateUtilException |
void | rollbackTransaction () throws HibernateUtilException |
void | reconnect (Session session) throws HibernateUtilException |
Session | disconnectSession () throws HibernateUtilException |
void | registerInterceptor (Interceptor interceptor) |
List | getList (Class type) throws HibernateUtilException |
Static Public Member Functions | |
static synchronized HibernateUtil | getInstance (Logger logger) |
static void | clearInstance () |
Static Public Attributes | |
static final String | HIBERNATE_FILENAME_DEFAULT = "cdb_rdb-hibernate.cfg.xml" |
Basic Hibernate helper class, handles SessionFactory, Session and Transaction.
Holds Session and Transactions in thread local variables. All exceptions are wrapped in an unchecked HibernateUtilException.
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.beginTransaction | ( | ) | throws HibernateUtilException |
Start a new database transaction.
Referenced by com.cosylab.cdb.jdal.HibernateWDALImpl.loadXMLCDB().
static void com.cosylab.cdb.jdal.hibernate.HibernateUtil.clearInstance | ( | ) | [static] |
Nulls the instance field, so that subsequent calls to getInstance(Logger) will create a new instance. This probably only makes sense between junit tests that want to start out fresh.
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.closeSession | ( | ) | throws HibernateUtilException |
Closes the Session local to the thread.
Referenced by com.cosylab.cdb.jdal.HibernateWDALImpl.loadXMLCDB().
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.commitTransaction | ( | ) | throws HibernateUtilException |
Commit the database transaction.
Referenced by com.cosylab.cdb.jdal.HibernateWDALImpl.loadXMLCDB().
Session com.cosylab.cdb.jdal.hibernate.HibernateUtil.disconnectSession | ( | ) | throws HibernateUtilException |
Disconnect and return Session from current Thread.
Configuration com.cosylab.cdb.jdal.hibernate.HibernateUtil.getConfiguration | ( | ) |
Returns the original Hibernate configuration.
static synchronized HibernateUtil com.cosylab.cdb.jdal.hibernate.HibernateUtil.getInstance | ( | Logger | logger | ) | [static] |
Singleton accessor
Referenced by com.cosylab.cdb.jdal.hibernate.HibernateDBUtil.HibernateDBUtil(), and com.cosylab.cdb.jdal.HibernateWDALImpl.HibernateWDALImpl().
List com.cosylab.cdb.jdal.hibernate.HibernateUtil.getList | ( | Class | type | ) | throws HibernateUtilException |
Session com.cosylab.cdb.jdal.hibernate.HibernateUtil.getSession | ( | ) | throws HibernateUtilException |
Retrieves the current Session local to the thread.
If no Session is open, opens a new Session for the running thread.
Referenced by com.cosylab.cdb.jdal.HibernateWDALImpl.getAlmaBranch(), com.cosylab.cdb.jdal.HibernateWDALImpl.getChannelsTableMap(), com.cosylab.cdb.jdal.HibernateWDALImpl.getComponentsTableMap(), com.cosylab.cdb.jdal.HibernateWDALImpl.getContainersTableMap(), com.cosylab.cdb.jdal.HibernateWDALImpl.initializeRootNode(), and com.cosylab.cdb.jdal.HibernateWDALImpl.loadXMLCDB().
SessionFactory com.cosylab.cdb.jdal.hibernate.HibernateUtil.getSessionFactory | ( | ) |
Returns the SessionFactory used for this static class.
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.rebuildSessionFactory | ( | Configuration | cfg | ) | throws HibernateUtilException |
Rebuild the SessionFactory with the given Hibernate Configuration.
cfg |
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.rebuildSessionFactory | ( | ) | throws HibernateUtilException |
Rebuild the SessionFactory with the static Configuration.
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.reconnect | ( | Session | session | ) | throws HibernateUtilException |
Reconnects a Hibernate Session to the current Thread.
session | The Hibernate Session to be reconnected. |
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.registerInterceptor | ( | Interceptor | interceptor | ) |
Register a Hibernate interceptor with the current thread.
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().
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.rollbackTransaction | ( | ) | throws HibernateUtilException |
Commit the database transaction.
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.setConfiguration | ( | Properties | extraProperties | ) |
Use default configuration and add properties from Properties. Build session factory from combined configuration.
config |
Referenced by com.cosylab.cdb.jdal.hibernate.HibernateDBUtil.setUp().
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.setConfiguration | ( | Configuration | config | ) |
Set your own configuration and build session factory from it. Used to tests.
config |
final String com.cosylab.cdb.jdal.hibernate.HibernateUtil.HIBERNATE_FILENAME_DEFAULT = "cdb_rdb-hibernate.cfg.xml" [static] |