Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes

com.cosylab.cdb.jdal.hibernate.HibernateUtil Class Reference

List of all members.

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"

Detailed Description

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.


Member Function Documentation

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.

Returns:
Session the disconnected Session
Configuration com.cosylab.cdb.jdal.hibernate.HibernateUtil.getConfiguration (  ) 

Returns the original Hibernate configuration.

Returns:
Configuration
static synchronized HibernateUtil com.cosylab.cdb.jdal.hibernate.HibernateUtil.getInstance ( Logger  logger  )  [static]
List com.cosylab.cdb.jdal.hibernate.HibernateUtil.getList ( Class  type  )  throws HibernateUtilException
Session com.cosylab.cdb.jdal.hibernate.HibernateUtil.getSession (  )  throws HibernateUtilException
SessionFactory com.cosylab.cdb.jdal.hibernate.HibernateUtil.getSessionFactory (  ) 

Returns the SessionFactory used for this static class.

Returns:
SessionFactory
void com.cosylab.cdb.jdal.hibernate.HibernateUtil.rebuildSessionFactory ( Configuration  cfg  )  throws HibernateUtilException

Rebuild the SessionFactory with the given Hibernate Configuration.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
config 

Member Data Documentation

final String com.cosylab.cdb.jdal.hibernate.HibernateUtil.HIBERNATE_FILENAME_DEFAULT = "cdb_rdb-hibernate.cfg.xml" [static]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations Properties