com.opnworks.timesheet.persistence
Class HibernateUtil

java.lang.Object
  extended bycom.opnworks.timesheet.persistence.HibernateUtil

public class HibernateUtil
extends java.lang.Object

A utility class that is used to configure and manage Hibernate connections

Author:
laurent

Field Summary
static java.lang.ThreadLocal session
          Description of the Field
 
Constructor Summary
HibernateUtil()
           
 
Method Summary
static void buildSessionFactory()
          Build a session factory using the receivers configuration and property
static void closeSession()
          Description of the Method
static net.sf.hibernate.Session currentSession()
          Return the current session
static void initialize()
          Initialize the instance using the hibernate.properties file if properties have not been set previously
static boolean isConnected()
           
static void setConnectionProperties(java.util.Properties properties)
           
static void setProperties(java.util.Properties properties)
          Set the properties of the class
static void setSessionFactory(net.sf.hibernate.SessionFactory factory)
           
static void shutdown()
          Method to shutdown the embedded database (HSQLDB ONLY!)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

public static final java.lang.ThreadLocal session
Description of the Field

Constructor Detail

HibernateUtil

public HibernateUtil()
Method Detail

setSessionFactory

public static void setSessionFactory(net.sf.hibernate.SessionFactory factory)
Parameters:
factory -

setConnectionProperties

public static void setConnectionProperties(java.util.Properties properties)
                                    throws TimesheetException
Parameters:
properties -
Throws:
TimesheetException - Description of Exception

setProperties

public static void setProperties(java.util.Properties properties)
Set the properties of the class

Parameters:
properties -

isConnected

public static boolean isConnected()
Returns:
The Connected value

initialize

public static void initialize()
                       throws TimesheetException
Initialize the instance using the hibernate.properties file if properties have not been set previously

Throws:
TimesheetException

buildSessionFactory

public static void buildSessionFactory()
                                throws net.sf.hibernate.HibernateException
Build a session factory using the receivers configuration and property

Throws:
net.sf.hibernate.HibernateException - Description of Exception

currentSession

public static net.sf.hibernate.Session currentSession()
                                               throws net.sf.hibernate.HibernateException
Return the current session

Returns:
Description of the Returned Value
Throws:
net.sf.hibernate.HibernateException

closeSession

public static void closeSession()
                         throws net.sf.hibernate.HibernateException
Description of the Method

Throws:
net.sf.hibernate.HibernateException

shutdown

public static void shutdown()
                     throws org.eclipse.core.runtime.CoreException
Method to shutdown the embedded database (HSQLDB ONLY!) Should not be invoked for server database cause it will cause a shutdown!

Throws:
org.eclipse.core.runtime.CoreException