public class SessionFactoryConfiguration extends Object
ServiceSessionControl.buildSessionFactory(SessionFactoryConfiguration)
.Modifier and Type | Field and Description |
---|---|
private String |
appId |
private Configuration |
cfg |
private int |
installedSchemaVersion |
private ClassLoader |
loader |
private String |
schema |
private int |
schemaVersion |
private boolean |
useSeparateConnections |
Constructor and Description |
---|
SessionFactoryConfiguration(String schema,
ClassLoader loader)
Create a configuration instance.
|
Modifier and Type | Method and Description |
---|---|
String |
getAppId()
Get the application id for schema versioning.
|
ClassLoader |
getClassLoader()
Get the schema.
|
Configuration |
getHibernateConfig()
Get the underlying Hibernate configuration instance.
|
int |
getInstalledSchemaVersion()
Get the schema version that was installed prior to updating it.
|
String |
getSchema()
Get the schema.
|
int |
getSchemaVersion()
Get the schema version of the current configuration.
|
void |
setInstalledSchemaVersion(int schemaVersion)
Callback intended for BASE core to set the installed schema version.
|
void |
setSchemaVersion(String appId,
int schemaVersion)
Set the schema version of the current configuration.
|
void |
setUseSeparateConnections(boolean separate)
Set to TRUE to use connections separate from BASE connections.
|
boolean |
useSeparateConnections()
Should the session factory be configured to use separate
connections or is piggy-backed sessions required?
|
private final String schema
private final ClassLoader loader
private final Configuration cfg
private String appId
private int schemaVersion
private int installedSchemaVersion
private boolean useSeparateConnections
public SessionFactoryConfiguration(String schema, ClassLoader loader)
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. http://hibernate.org/orm/documentation/)
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 tablesclassLoader
- The class loader that can load classes for the extension (needed by Hibernate)public String getSchema()
public ClassLoader getClassLoader()
public Configuration getHibernateConfig()
public void setSchemaVersion(String appId, int schemaVersion)
appId
- The application IDschemaVersion
- The schema version to installpublic String getAppId()
public int getSchemaVersion()
public int getInstalledSchemaVersion()
ServiceSessionControl.buildSessionFactory(SessionFactoryConfiguration)
.public void setInstalledSchemaVersion(int schemaVersion)
public boolean useSeparateConnections()
public void setUseSeparateConnections(boolean separate)
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.