org.openbp.server.persistence.hibernate
Class HibernatePersistenceContextProvider

java.lang.Object
  extended by org.openbp.server.persistence.BasicPersistenceContextProvider
      extended by org.openbp.server.persistence.hibernate.HibernatePersistenceContextProvider
All Implemented Interfaces:
PersistenceContextProvider, org.springframework.context.ApplicationContextAware

public class HibernatePersistenceContextProvider
extends BasicPersistenceContextProvider

Peristence context provider for a Hibernate-based persistence context.

Author:
Heiko Erhardt

Field Summary
protected  org.hibernate.SessionFactory sessionFactory
          Session factory
 
Fields inherited from class org.openbp.server.persistence.BasicPersistenceContextProvider
applicationContext, entityToBeanClassMap, threadContext
 
Constructor Summary
HibernatePersistenceContextProvider()
          Constructor.
 
Method Summary
static void addOpenBPClassMappingsToConfiguration(org.hibernate.cfg.Configuration configuration)
          Adds class mappings for the OpenBP classes to the given Hibernate configuration object.
 org.hibernate.cfg.Configuration createHibernateConfiguration()
          Creates a Hibernate configuration object that includes the OpenBP classes.
protected  PersistenceContext createPersistenceContext()
          Creates a new persistence context.
protected  org.hibernate.SessionFactory createSessionFactory()
          Creates a Hibernate session factory.
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Sets the session factory.
 void shutdown()
          The shutdown method .
 
Methods inherited from class org.openbp.server.persistence.BasicPersistenceContextProvider
createEntity, determineEntityClass, initialize, instantiateEntity, isTransactional, obtainExistingPersistenceContext, obtainPersistenceContext, setApplicationContext, setTransactional, toString, tryEntityDefaults, unbindThreadContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionFactory

protected transient org.hibernate.SessionFactory sessionFactory
Session factory

Constructor Detail

HibernatePersistenceContextProvider

public HibernatePersistenceContextProvider()
Constructor.

Method Detail

shutdown

public void shutdown()
The shutdown method .

Specified by:
shutdown in interface PersistenceContextProvider
Overrides:
shutdown in class BasicPersistenceContextProvider

createPersistenceContext

protected PersistenceContext createPersistenceContext()
                                               throws PersistenceException
Creates a new persistence context.

Specified by:
createPersistenceContext in class BasicPersistenceContextProvider
Returns:
The new context
Throws:
PersistenceException - On error (e. g. if there is no database defined or a database session cannot be established)

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Sets the session factory.


createSessionFactory

protected org.hibernate.SessionFactory createSessionFactory()
                                                     throws PersistenceException
Creates a Hibernate session factory.

Returns:
The new factory or null
Throws:
PersistenceException - On error (e. g. database/hibernate.properties missing or invalid)

createHibernateConfiguration

public org.hibernate.cfg.Configuration createHibernateConfiguration()
Creates a Hibernate configuration object that includes the OpenBP classes. Adds the following class mappings (if not present yet):
TokenContextImpl
WorkflowTaskImpl
DbModel
DbModelItem

Returns:
The new configuration object

addOpenBPClassMappingsToConfiguration

public static void addOpenBPClassMappingsToConfiguration(org.hibernate.cfg.Configuration configuration)
Adds class mappings for the OpenBP classes to the given Hibernate configuration object. Adds the following class mappings (if not present yet):
TokenContextImpl
WorkflowTaskImpl
DbModel
DbModelItem

Parameters:
configuration - The configuration


Copyright © 2011. All Rights Reserved.