Class 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 Detail

      • SessionFactoryController

        public SessionFactoryController()
    • 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 the DalContextListener, 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
      • 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 the SessionFactory
      • getSQLFunctions

        protected Map<String,​org.hibernate.dialect.function.SQLFunction> getSQLFunctions()
      • 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