com.xenonsoft.bridgetown.aop.transaction.hibernate
Class HibernateUtil

java.lang.Object
  extended bycom.xenonsoft.bridgetown.aop.transaction.hibernate.HibernateUtil
All Implemented Interfaces:
IAfterPropertyInjection, IDisposable

public class HibernateUtil
extends java.lang.Object
implements IAfterPropertyInjection, IDisposable

Utility object for Hibernate, contains static methods to retrieving the session factory and demarcating transactions.

This code is modified from Hibernate in Action book. See the classic book: "Hibernate in Action", by Bauer and King, publ. Manning. ISBN 1-932394-15-X

Version:
$Id: HibernateUtil.java,v 1.2 2005/03/29 23:41:23 peter_pilgrim Exp $
Author:
Peter Pilgrim, 10-Mar-2005 17:21:53

Constructor Summary
HibernateUtil()
          Default constructor
 
Method Summary
 void afterPropertyInit()
          Creates a Hibernate configuration and reads it from preference store.
static void beginTransaction()
          Begins a Hibernate transaction
static void closeSession()
          Close the Hibernate session
static void commitTransaction()
          Commits a Hibernate transaction
 void dispose()
          Dispose of the hibernate session factory, if it was ever created
 java.lang.String getConfiguration()
          Gets the Hibernate configuration
 java.util.List getPersistenceClasses()
          Gets the persistenceClasses
static net.sf.hibernate.Session getSession()
          Open a new Hibernate or retrieve an existing Hibernate session
static void rollbackTransaction()
          Rolls back a Hibernate transaction
 void setConfiguration(java.lang.String configuration)
          Sets the Hibernate configuration
 void setPersistenceClasses(java.util.List persistenceClasses)
          Sets the persistenceClasses
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateUtil

public HibernateUtil()
Default constructor

Method Detail

getConfiguration

public java.lang.String getConfiguration()
Gets the Hibernate configuration

Returns:
Returns the configuration.

setConfiguration

public void setConfiguration(java.lang.String configuration)
Sets the Hibernate configuration

Parameters:
configuration - the new value for configuration

getPersistenceClasses

public java.util.List getPersistenceClasses()
Gets the persistenceClasses

Returns:
Returns the persistenceClasses.

setPersistenceClasses

public void setPersistenceClasses(java.util.List persistenceClasses)
Sets the persistenceClasses

Parameters:
persistenceClasses - The persistenceClasses to set.

afterPropertyInit

public void afterPropertyInit()
Creates a Hibernate configuration and reads it from preference store. Afterwards obtains a session factory.

Specified by:
afterPropertyInit in interface IAfterPropertyInjection
Throws:
InfrastructureException - if a persistence class cannot be found or loaded successfully

dispose

public void dispose()
Dispose of the hibernate session factory, if it was ever created

Specified by:
dispose in interface IDisposable
See Also:
IDisposable.dispose()

getSession

public static net.sf.hibernate.Session getSession()
Open a new Hibernate or retrieve an existing Hibernate session

Returns:
the Hibernate session

closeSession

public static void closeSession()
Close the Hibernate session


beginTransaction

public static void beginTransaction()
Begins a Hibernate transaction


commitTransaction

public static void commitTransaction()
Commits a Hibernate transaction


rollbackTransaction

public static void rollbackTransaction()
Rolls back a Hibernate transaction



Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.