Package net.sf.basedb.core.hibernate
Class SessionFactoryConfiguration
java.lang.Object
net.sf.basedb.core.hibernate.SessionFactoryConfiguration
Deprecated.
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.
- Since:
- 3.4
- Author:
- nicklas
-
Constructor Summary
ConstructorDescriptionSessionFactoryConfiguration
(String schema, ClassLoader loader) Deprecated.Create a configuration instance. -
Method Summary
Modifier and TypeMethodDescriptiongetAppId()
Deprecated.Get the application id for schema versioning.Deprecated.Get the schema.Deprecated.Get the underlying Hibernate configuration instance.int
Deprecated.Get the schema version that was installed prior to updating it.Deprecated.Get the schema.int
Deprecated.Get the schema version of the current configuration.void
setInstalledSchemaVersion
(int schemaVersion) Deprecated.Callback intended for BASE core to set the installed schema version.void
setSchemaVersion
(String appId, int schemaVersion) Deprecated.Set the schema version of the current configuration.void
setUseSeparateConnections
(boolean separate) Deprecated.Set to TRUE to use connections separate from BASE connections.boolean
Deprecated.Should the session factory be configured to use separate connections or is piggy-backed sessions required?
-
Constructor Details
-
SessionFactoryConfiguration
Deprecated.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 callingsetSchemaVersion(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. UsegetHibernateConfig()
to retrieve the backend Hibernate configuration instance. If you have annotated entity classes you can add them withConfiguration.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. http://hibernate.org/orm/documentation/) Also note that by default the configured session factory need to be "piggy-backed" on a BASEDbControl
transaction. Create Hibernate sessions withServiceSessionControl.newSession(org.hibernate.SessionBuilder, DbControl)
. If you want to use connections/transactions that are independent from BASE calluseSeparateConnections()
but make sure you also get connection pooling configured. You can still use "piggy-backed" connections.- Parameters:
schema
- The schema name the extension wants to use for it's database tablesloader
- The class loader that can load classes for the extension (needed by Hibernate)
-
-
Method Details
-
getSchema
Deprecated.Get the schema. -
getClassLoader
Deprecated.Get the schema. -
getHibernateConfig
Deprecated.Get the underlying Hibernate configuration instance. You will need this to defined mappings between entities and database tables. -
setSchemaVersion
Deprecated.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.- Parameters:
appId
- The application IDschemaVersion
- The schema version to install
-
getAppId
Deprecated.Get the application id for schema versioning. -
getSchemaVersion
public int getSchemaVersion()Deprecated.Get the schema version of the current configuration. -
getInstalledSchemaVersion
public int getInstalledSchemaVersion()Deprecated.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) Deprecated.Callback intended for BASE core to set the installed schema version. -
useSeparateConnections
public boolean useSeparateConnections()Deprecated.Should the session factory be configured to use separate connections or is piggy-backed sessions required? -
setUseSeparateConnections
public void setUseSeparateConnections(boolean separate) Deprecated.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 ongetHibernateConfig()
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.
-
ServiceSessionControl.createSessionFactoryConfiguration(String, String, int, ClassLoader)
instead