Class SessionFactoryConfiguration


public class SessionFactoryConfiguration
extends Object
Class for holding configuration options for creating extra session factories for services. Used by ServiceSessionControl#buildSessionFactory(SessionFactoryConfiguration).

This class has been deprecated and can no longer be used for configuring session factories. Extensions should use ServiceSessionControl.createSessionFactoryConfiguration(String, String, int, ClassLoader) instead which will provide similar functionality.

  • Constructor Details

    • SessionFactoryConfiguration

      public SessionFactoryConfiguration​(String schema, ClassLoader loader)
      Create a configuration instance. A schema is required and is the place were tabales for configured classes will be created. A class loader is needed so that Hibernate can load the classes from extension classes. It is recommended that an "application id" and schema version is set by calling setSchemaVersion(String, int). Then, BASE can check the currently installed schema version and only update the database if there is a change. Note that the schema version must always increase from one version to the next. Use getHibernateConfig() to retrieve the backend Hibernate configuration instance. If you have annotated entity classes you can add them with Configuration.addAnnotatedClass(Class), but there are a lots of other configuration possibilities that are beyond the scope of this documentation. A good Hibernate tutorial is recommended (eg. Also note that by default the configured session factory need to be "piggy-backed" on a BASE DbControl transaction. Create Hibernate sessions with ServiceSessionControl.newSession(org.hibernate.SessionBuilder, DbControl). If you want to use connections/transactions that are independent from BASE call useSeparateConnections() but make sure you also get connection pooling configured. You can still use "piggy-backed" connections.
      schema - The schema name the extension wants to use for it's database tables
      loader - The class loader that can load classes for the extension (needed by Hibernate)
  • Method Details

    • getSchema

      public String getSchema()
      Get the schema.
    • getClassLoader

      public ClassLoader getClassLoader()
      Get the schema.
    • getHibernateConfig

      public Configuration getHibernateConfig()
      Get the underlying Hibernate configuration instance. You will need this to defined mappings between entities and database tables.
    • setSchemaVersion

      public void setSchemaVersion​(String appId, int schemaVersion)
      Set the schema version of the current configuration. If this information has been set, BASE will check the current schema version registration and only issue a database update in case the registered schema version is lower than the given. If the registered version is higher the session factory creation fails. If no schema version has been set, BASE will always try a database update.
      appId - The application ID
      schemaVersion - The schema version to install
    • getAppId

      public String getAppId()
      Get the application id for schema versioning.
    • getSchemaVersion

      public int getSchemaVersion()
      Get the schema version of the current configuration.
    • getInstalledSchemaVersion

      public int getInstalledSchemaVersion()
      Get the schema version that was installed prior to updating it. Note that this value is only available after calling ServiceSessionControl#buildSessionFactory(SessionFactoryConfiguration).
    • setInstalledSchemaVersion

      public void setInstalledSchemaVersion​(int schemaVersion)
      Callback intended for BASE core to set the installed schema version.
    • useSeparateConnections

      public boolean useSeparateConnections()
      Should the session factory be configured to use separate connections or is piggy-backed sessions required?
    • setUseSeparateConnections

      public void setUseSeparateConnections​(boolean separate)
      Set to TRUE to use connections separate from BASE connections. If you enable this, you will probably also want to configure connection pooling since the default connection pooling is not recommended for production use. Connection pooling is configured on getHibernateConfig() object. Basically you need to set the 'connection.provider_class' property to 'org.hibernate.connection.C3P0ConnectionProvider' and some other properties. You'll need to look for this documentation in other places.