com.sas.framework.expojo.hibernate
Class HibernatePersistenceProvider

java.lang.Object
  extended by com.sas.framework.expojo.PersistenceProvider
      extended by com.sas.framework.expojo.hibernate.HibernatePersistenceProvider

public class HibernatePersistenceProvider
extends PersistenceProvider

Provides persistence using Hibernate.


Field Summary
protected  Session session
          Hibernate session.
protected  SessionFactory sessionFactory
          Hibernate session factory.
protected  Transaction transaction
          The current transaction for the session, null if no transaction is currently associated with the session.
 
Fields inherited from class com.sas.framework.expojo.PersistenceProvider
depth, modelExposer
 
Constructor Summary
HibernatePersistenceProvider(SessionFactory iSessionFactory)
          Constructs the object giving it a SessionFactory so that it can make it's own Session(s).
 
Method Summary
 void beginTx()
          Begins a transaction.
 void close()
          Closes the persistence provider.
 void commitTx()
          Commits a transaction.
 void delete(java.lang.Object object)
          Deletes the persistent object from the datastore.
 Session getSession()
          Returns session
 SessionFactory getSessionFactory()
          Returns sessionFactory
 Transaction getTransaction()
          Returns transaction
 boolean hasActiveTx()
          Returns true if the PersistenceProvider has an active transaction.
 void open()
          Opens a persistence provider.
 void persist(java.lang.Object object)
          Makes the given object persistent.
 java.lang.RuntimeException processException(java.lang.RuntimeException e)
          Processes an exception thrown while in a transaction.
 void rollbackTx()
          Rolls back a transaction.
 void setSession(Session session)
          Sets session
 void setSessionFactory(SessionFactory sessionFactory)
          Sets sessionFactory
 void setTransaction(Transaction transaction)
          Sets transaction
 
Methods inherited from class com.sas.framework.expojo.PersistenceProvider
setModelExposer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

session

protected transient Session session
Hibernate session.


sessionFactory

protected transient SessionFactory sessionFactory
Hibernate session factory.


transaction

protected transient Transaction transaction
The current transaction for the session, null if no transaction is currently associated with the session.

Constructor Detail

HibernatePersistenceProvider

public HibernatePersistenceProvider(SessionFactory iSessionFactory)
Constructs the object giving it a SessionFactory so that it can make it's own Session(s).

Method Detail

hasActiveTx

public boolean hasActiveTx()
Returns true if the PersistenceProvider has an active transaction.

Specified by:
hasActiveTx in class PersistenceProvider

setTransaction

public void setTransaction(Transaction transaction)
Sets transaction


getTransaction

public Transaction getTransaction()
Returns transaction


setSession

public void setSession(Session session)
Sets session


getSession

public Session getSession()
Returns session


setSessionFactory

public void setSessionFactory(SessionFactory sessionFactory)
Sets sessionFactory


getSessionFactory

public SessionFactory getSessionFactory()
Returns sessionFactory


open

public void open()
Opens a persistence provider.

Specified by:
open in class PersistenceProvider

processException

public java.lang.RuntimeException processException(java.lang.RuntimeException e)
Processes an exception thrown while in a transaction. The exception could be relevent to the persistence technology or a generic RuntimeException. If it's an optimistic verification exception (optimistic locking check failed) then no exception is thrown and the persistence technology may or may not need clean. In the case of JDO a rollback as already been performed.

Specified by:
processException in class PersistenceProvider

close

public void close()
Closes the persistence provider. It can no longer be used after being closed.

Specified by:
close in class PersistenceProvider

delete

public void delete(java.lang.Object object)
Deletes the persistent object from the datastore.

Specified by:
delete in class PersistenceProvider

persist

public void persist(java.lang.Object object)
Makes the given object persistent.

Specified by:
persist in class PersistenceProvider

rollbackTx

public void rollbackTx()
Rolls back a transaction.

Specified by:
rollbackTx in class PersistenceProvider

beginTx

public void beginTx()
Begins a transaction.

Specified by:
beginTx in class PersistenceProvider

commitTx

public void commitTx()
Commits a transaction.

Specified by:
commitTx in class PersistenceProvider