|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectto.etc.domui.hibernate.config.HibernateConfigurator
public final class HibernateConfigurator
Helper class to help with configuring Hibernate for DomUI easily. You are not required to use this class at all; "normal" hibernate configuration works as "well" (meh), but this tries to hide lots of boilerplate needed to configure properly while only exposing that which is really needed in most cases.
Nested Class Summary | |
---|---|
static class |
HibernateConfigurator.Mode
Defines the database update mode (hibernate.hbm2ddl.auto). |
Constructor Summary | |
---|---|
HibernateConfigurator()
|
Method Summary | |
---|---|
static void |
addClasses(java.lang.Class<?>... classes)
Must be called before one of the "initialize" methods gets called, to register all POJO classes that need to be configured with Hibernate. |
static QDataContextFactory |
getDataContextFactory()
Returns the data context factory wrapping the hibernate code. |
static javax.sql.DataSource |
getDataSource()
Return the datasource, as configured. |
static SessionFactory |
getSessionFactory()
Return the Hibernate SessionFactory created by this code. |
static void |
initialize(javax.sql.DataSource ds)
Main worker to initialize the database layer, using Hibernate, with a user-specified core data source. |
static void |
initialize(java.io.File poolfile,
java.lang.String poolname)
Initialize the layer using a poolid in the specified poolfile. |
static void |
initialize(java.lang.String poolname)
Alternate entrypoint: initialize the layer using a poolID in the default poolfile. |
static Session |
internalGetSession(QDataContext dc)
Unwrap the QDataContext and obtain it's Hibernate Session record. |
static void |
registerQueryExecutor(IQueryExecutorFactory qexecutor)
Register an alternative IQueryExecutorFactory which can execute QCriteria queries on non-hibernate
classes. |
static void |
registerQueryListener(IQueryListener ql)
Register a DomUI IQueryListener that will be called when DomUI executes QCriteria queries. |
static void |
schemaUpdate(HibernateConfigurator.Mode m)
Set the "schema update" mode for Hibernate (corresponding to hbm2ddl.auto). |
static void |
showSQL(boolean on)
Set the "show sql" setting for hibernate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HibernateConfigurator()
Method Detail |
---|
@Nonnull public static javax.sql.DataSource getDataSource()
public static SessionFactory getSessionFactory()
public static Session internalGetSession(QDataContext dc) throws java.lang.Exception
Session
record.
dc
-
java.lang.Exception
public static QDataContextFactory getDataContextFactory()
public static void addClasses(java.lang.Class<?>... classes)
public static void showSQL(boolean on)
on
- public static void schemaUpdate(@Nonnull HibernateConfigurator.Mode m)
m
- public static void registerQueryListener(IQueryListener ql)
IQueryListener
that will be called when DomUI executes QCriteria
queries.
ql
- public static void registerQueryExecutor(IQueryExecutorFactory qexecutor)
IQueryExecutorFactory
which can execute QCriteria queries on non-hibernate
classes. WARNING: if
you use this call all default query executors are not registered. This allows you to override them if needed. It also
means that no Hibernate QCriteria code works at all if you do not add them! The default factories should be registered
as follows:
registerQueryListener(JdbcQueryExecutor.FACTORY); registerQueryListener(HibernateQueryExecutor.FACTORY);By ordering your executors with the default ones you can control the order of acceptance for queries.
qexecutor
- public static void initialize(javax.sql.DataSource ds) throws java.lang.Exception
ds
-
java.lang.Exception
public static void initialize(java.lang.String poolname) throws java.lang.Exception
poolname
-
java.lang.Exception
public static void initialize(java.io.File poolfile, java.lang.String poolname) throws java.lang.Exception
poolfile
- poolname
-
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |