Package org.openbravo.base.session
Class SessionFactoryController
- java.lang.Object
-
- org.openbravo.base.session.SessionFactoryController
-
- Direct Known Subclasses:
DalSessionFactoryController
,ModelSessionFactoryController
public abstract class SessionFactoryController extends Object
Initializes and provides the session factory to the rest of the application. There are subclasses for for the bootstrap process and the runtime process.- Author:
- mtaal
-
-
Constructor Summary
Constructors Constructor Description SessionFactoryController()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected org.hibernate.cfg.Configuration
buildConfiguration()
Creates the Configuration instance used to build the SessionFactory.void
closeHibernatePool()
String
getColumnMetadataQuery()
Returns a query for column metadata for not-null/required which is specific for Postgres or Oracle.org.hibernate.cfg.Configuration
getConfiguration()
static SessionFactoryController
getInstance()
protected Properties
getOpenbravoProperties()
org.hibernate.SessionFactory
getSessionFactory()
protected Map<String,org.hibernate.dialect.function.SQLFunction>
getSQLFunctions()
String
getUniqueConstraintQuery()
Returns a query which is specific for Postgres or Oracle.void
initialize()
Creates a new Hibernate Configuration, generates a mapping and initializes the SessionFactory.boolean
isInitialized()
static boolean
isJNDIModeOn(Properties obProps)
jndi should only be used if the application is running in a webcontainer in all other cases (ant etc.) jndi should not be used, but the direct openbravo.properties should be used.static boolean
isRunningInWebContainer()
Keeps track if the Dal layer runs within Tomcat or within for example an Ant task.protected abstract void
mapModel(org.hibernate.cfg.Configuration theConfiguration)
void
reInitialize()
Resets and initializes the SessionFactory.static void
setInstance(SessionFactoryController sfc)
protected void
setInterceptor(org.hibernate.cfg.Configuration configuration)
static void
setRunningInWebContainer(boolean runningInWebContainer)
Is set from theDalContextListener
, keeps track if the Dal layer runs within Tomcat or within for example an Ant task.
-
-
-
Method Detail
-
isRunningInWebContainer
public static boolean isRunningInWebContainer()
Keeps track if the Dal layer runs within Tomcat or within for example an Ant task.- Returns:
- true if the current Dal layer runs within Tomcat, false otherwise
-
setRunningInWebContainer
public static void setRunningInWebContainer(boolean runningInWebContainer)
Is set from theDalContextListener
, keeps track if the Dal layer runs within Tomcat or within for example an Ant task.- Parameters:
runningInWebContainer
- true if running in a webcontainer such as Tomcat
-
getInstance
public static SessionFactoryController getInstance()
-
setInstance
public static void setInstance(SessionFactoryController sfc)
-
getSessionFactory
public org.hibernate.SessionFactory getSessionFactory()
-
getConfiguration
public org.hibernate.cfg.Configuration getConfiguration()
-
isInitialized
public boolean isInitialized()
-
reInitialize
public void reInitialize()
Resets and initializes the SessionFactory. If there is a SessionFactory then this one is first closed before a new one is created.
-
initialize
public void initialize()
Creates a new Hibernate Configuration, generates a mapping and initializes the SessionFactory.
-
buildConfiguration
protected org.hibernate.cfg.Configuration buildConfiguration()
Creates the Configuration instance used to build the SessionFactory. It can be extended by the subclasses for example if they need to register a Service Provider Interface to customize the Hibernate internals.- Returns:
- a
Configuration
instance used to build theSessionFactory
-
closeHibernatePool
public void closeHibernatePool()
-
mapModel
protected abstract void mapModel(org.hibernate.cfg.Configuration theConfiguration)
-
getOpenbravoProperties
protected Properties getOpenbravoProperties()
-
isJNDIModeOn
public static boolean isJNDIModeOn(Properties obProps)
jndi should only be used if the application is running in a webcontainer in all other cases (ant etc.) jndi should not be used, but the direct openbravo.properties should be used.
-
setInterceptor
protected void setInterceptor(org.hibernate.cfg.Configuration configuration)
-
getUniqueConstraintQuery
public String getUniqueConstraintQuery()
Returns a query which is specific for Postgres or Oracle.- Returns:
- depending on the Openbravo.properties a Postgres or Oracle specific query is returned
-
getColumnMetadataQuery
public String getColumnMetadataQuery()
Returns a query for column metadata for not-null/required which is specific for Postgres or Oracle.- Returns:
- depending on the Openbravo.properties a Postgres or Oracle specific query is returned
-
-