org.yawlfoundation.yawl.engine
Class YPersistenceManager

java.lang.Object
  extended by org.yawlfoundation.yawl.engine.YPersistenceManager

public class YPersistenceManager
extends Object

This class acts as a handler for transactional persistence within the engine.

Author:
Andrew Hastie (M2 Investments) Date: 21/06/2005 Time: 13:46:54, Michael Adams - updated for v2.1 11/2009

Field Summary
static int DB_DELETE
           
static int DB_INSERT
           
static int DB_UPDATE
           
 
Constructor Summary
YPersistenceManager()
          Constructor
 
Method Summary
 void closeFactory()
           
 void closeSession()
           
 void commit()
           
 org.hibernate.Query createQuery(String queryString)
           
protected  void deleteObject(Object obj)
          Causes the supplied object to be removed from the persistence cache when the current transaction is committed.
 void deleteObjectFromExternal(Object obj)
          Causes the supplied object to be unpersisted when the current transaction is committed.
 List execQuery(org.hibernate.Query query)
          executes a Query object based on the sql string passed
 List execQuery(String queryString)
           
 org.hibernate.SessionFactory getFactory()
           
 List getObjectsForClass(String className)
          returns all the instances currently persisted for the class passed
 List getObjectsForClassWhere(String className, String whereClause)
          returns all the instances currently persisted for the class passed that match the condition specified in the where clause
 org.hibernate.Session getSession()
           
 String getStatistics()
           
 org.hibernate.Transaction getTransaction()
           
protected  org.hibernate.SessionFactory initialise(boolean journalising)
           
 boolean isEnabled()
           
 boolean isRestoring()
           
 boolean isStatisticsEnabled()
           
protected  void rollbackTransaction()
          Forces a rollback of the current transaction,
 Object selectScalar(String className, String field, long value)
          same as above but takes a long value instead
 Object selectScalar(String className, String field, String value)
          gets a scalar value (as an object) based on the values passed
 void setEnabled(boolean enable)
           
protected  void setRestoring(boolean restoring)
           
 void setStatisticsEnabled(boolean enabled)
           
 boolean startTransaction()
          Start a new Hibernate transaction.
protected  void storeObject(Object obj)
          Persists an object.
 void storeObjectFromExternal(Object obj)
          Causes the supplied object to be persisted when the current transaction is committed.
protected  void updateObject(Object obj)
          Causes the supplied object to be updated when the current transaction is committed.
 void updateObjectExternal(Object obj)
          Causes the supplied object to be updated within the persistence cache when the current transaction is committed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DB_UPDATE

public static final int DB_UPDATE
See Also:
Constant Field Values

DB_DELETE

public static final int DB_DELETE
See Also:
Constant Field Values

DB_INSERT

public static final int DB_INSERT
See Also:
Constant Field Values
Constructor Detail

YPersistenceManager

public YPersistenceManager()
Constructor

Method Detail

initialise

protected org.hibernate.SessionFactory initialise(boolean journalising)
                                           throws YPersistenceException
Throws:
YPersistenceException

setEnabled

public void setEnabled(boolean enable)

isEnabled

public boolean isEnabled()

getFactory

public org.hibernate.SessionFactory getFactory()

isRestoring

public boolean isRestoring()

setRestoring

protected void setRestoring(boolean restoring)

getSession

public org.hibernate.Session getSession()

getTransaction

public org.hibernate.Transaction getTransaction()

closeSession

public void closeSession()

closeFactory

public void closeFactory()

getStatistics

public String getStatistics()

setStatisticsEnabled

public void setStatisticsEnabled(boolean enabled)

isStatisticsEnabled

public boolean isStatisticsEnabled()

startTransaction

public boolean startTransaction()
                         throws YPersistenceException
Start a new Hibernate transaction.

Returns:
true if a transaction is started successfully, false if the session already has an active transaction
Throws:
YPersistenceException - if there's a problem starting a transaction

storeObject

protected void storeObject(Object obj)
                    throws YPersistenceException
Persists an object.

Parameters:
obj - The object to be persisted
Throws:
YPersistenceException

updateObject

protected void updateObject(Object obj)
                     throws YPersistenceException
Causes the supplied object to be updated when the current transaction is committed.

Parameters:
obj - The object to be persisted
Throws:
YPersistenceException

deleteObject

protected void deleteObject(Object obj)
                     throws YPersistenceException
Causes the supplied object to be removed from the persistence cache when the current transaction is committed.

Parameters:
obj - The object to be persisted
Throws:
YPersistenceException

storeObjectFromExternal

public void storeObjectFromExternal(Object obj)
                             throws YPersistenceException
Causes the supplied object to be persisted when the current transaction is committed. This method simply calls storeObject(Object) but is public in scope.

Parameters:
obj - The object to be persisted
Throws:
YPersistenceException

updateObjectExternal

public void updateObjectExternal(Object obj)
                          throws YPersistenceException
Causes the supplied object to be updated within the persistence cache when the current transaction is committed. This method simply calls updateObject(Object) but is public in scope.

Parameters:
obj - The object to be persisted
Throws:
YPersistenceException

deleteObjectFromExternal

public void deleteObjectFromExternal(Object obj)
                              throws YPersistenceException
Causes the supplied object to be unpersisted when the current transaction is committed. This method simply calls deleteObject(Object) but is public in scope.

Parameters:
obj - The object to be unpersisted
Throws:
YPersistenceException

commit

public void commit()
            throws YPersistenceException
Throws:
YPersistenceException

rollbackTransaction

protected void rollbackTransaction()
                            throws YPersistenceException
Forces a rollback of the current transaction,

Throws:
YPersistenceException

createQuery

public org.hibernate.Query createQuery(String queryString)
                                throws YPersistenceException
Throws:
YPersistenceException

execQuery

public List execQuery(String queryString)
               throws YPersistenceException
Throws:
YPersistenceException

execQuery

public List execQuery(org.hibernate.Query query)
               throws YPersistenceException
executes a Query object based on the sql string passed

Parameters:
query - - the sql query to execute
Returns:
the List of objects returned
Throws:
YPersistenceException - if there's a problem reading the db

getObjectsForClass

public List getObjectsForClass(String className)
                        throws YPersistenceException
returns all the instances currently persisted for the class passed

Parameters:
className - - the name of the class to retrieve instances of
Returns:
a List of the instances retrieved
Throws:
YPersistenceException - if there's a problem reading the db

getObjectsForClassWhere

public List getObjectsForClassWhere(String className,
                                    String whereClause)
                             throws YPersistenceException
returns all the instances currently persisted for the class passed that match the condition specified in the where clause

Parameters:
className - the name of the class to retrieve instances of
whereClause - the condition (without the 'where' part) e.g. "age=21"
Returns:
a List of the instances retrieved
Throws:
YPersistenceException - if there's a problem reading the db

selectScalar

public Object selectScalar(String className,
                           String field,
                           String value)
                    throws YPersistenceException
gets a scalar value (as an object) based on the values passed

Parameters:
className - - the type of object to select
field - - the column name which contains the queried value
value - - the value to find in the 'field' column
Returns:
the first (or only) object matching 'where [field] = [value]'
Throws:
YPersistenceException

selectScalar

public Object selectScalar(String className,
                           String field,
                           long value)
                    throws YPersistenceException
same as above but takes a long value instead

Throws:
YPersistenceException


Copyright © 2004-2012 The YAWL Foundation.