Class ServiceSessionControl.SessionFactoryConfiguration

java.lang.Object
net.sf.basedb.core.ServiceSessionControl.SessionFactoryConfiguration
Enclosing class:
ServiceSessionControl

public class ServiceSessionControl.SessionFactoryConfiguration extends Object
Used for creating a configuration that is the basis for building a session factory. The typical workflow is: 1. Create an instance of this class by calling ServiceSessionControl.createSessionFactoryConfiguration(String, String, int, ClassLoader) 2. Set configuration properties on getRegistryBuilder() 3. Add mapped entity classes on getMetadataSources() 4. Build the session factory: ServiceSessionControl.buildSessionFactory(SessionFactoryConfiguration) Store the created session factory in a service instance variable. When a database connection is needed use: 1. ServiceSessionControl.newSession(SessionBuilder, DbControl): for a transaction that is piggy-backed on a BASE DbControl 2. SessionFactory.openSession(): for a standalone transaction.
Since:
3.8
  • Field Details

    • appId

      private final String appId
    • schema

      private final String schema
    • schemaVersion

      private final int schemaVersion
    • classLoader

      private final ClassLoader classLoader
    • registryBuilder

      private StandardServiceRegistryBuilder registryBuilder
    • metadataSources

      private MetadataSources metadataSources
    • actualCatalog

      private String actualCatalog
    • actualSchema

      private String actualSchema
    • installMode

      private SchemaGenerator.Mode installMode
    • installedSchemaVersion

      private int installedSchemaVersion
    • useSeparateConnections

      private boolean useSeparateConnections
  • Constructor Details

    • SessionFactoryConfiguration

      SessionFactoryConfiguration(String appId, String schema, int schemaVersion, ClassLoader classLoader)
  • Method Details

    • init

      void init()
    • getSchema

      public String getSchema()
      Get the schema.
    • getAppId

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

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

      public SchemaGenerator.Mode getInstallMode()
      Get the installation mode that BASE will use when creating the session factory. Returns null if no install/update is needed.
    • getInstalledSchemaVersion

      public int getInstalledSchemaVersion()
      Get the currently installed version of the schema or 0 if not installed.
    • getActualSchema

      public String getActualSchema()
      The actual schema that will be used by BASE.
    • getActualCatalog

      public String getActualCatalog()
      The actual catalog that will be used by BASE.
    • getClassLoader

      public ClassLoader getClassLoader()
      Get the class loader used for accessing mapped classes.
    • 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 getRegistryBuilder() 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.
    • useSeparateConnections

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

      private void checkLocked(String method)
      Check that the
    • getRegistryBuilder

      public StandardServiceRegistryBuilder getRegistryBuilder()
      Get the registry for collecting configuration options. The registry is used for configuration options that go into the hibernate.cfg.xml file. Note that BASE will automatially add configuration options for connecting to the database and the following options will be overwritten:

      hibernate.dialect hibernate.connection_driver_class hibernate.default_catalog hibernate.default_schema hibernate.connection.url hibernate.connection.username hibernate.connection.password

      The registry must be fully configured before calling getMetadataSources(). This method will throw an exception if called in the incorrect order.

    • getMetadataSources

      public MetadataSources getMetadataSources()
      Get an object for registering mapped entity classes. Once this method has been called it is not possible to modify the registry builder or other configuration settings.