Class HibernateUtil
- Version:
- 2.0
- Author:
- Nicklas, Samuel
- Last modified
- $Date: 2024-05-20 08:31:12 +0200 (Mon, 20 May 2024) $
-
Nested Class Summary
Modifier and TypeClassDescription(package private) static class
(package private) static class
Helper class for defining filters at runtime. -
Field Summary
Modifier and TypeFieldDescriptionprivate static MetadataSources
The Hibernate configuration, including all mappings.private static DbEngine
Our extra database specific sql generation that is not possible by the Hibernate dialect.private static Dialect
The Hibernate database dialect in use.private static boolean
private static int
Number of rows to load at a time when iterating over a result set.private static final Logger
Log core events.private static final Logger
Log all batcher SQL statements.private static Metadata
The mappings related to a configuration.private static SessionFactory
The single SessionFactory. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
addColumn
(MetadataImplementor metadata, Table hibernateTable, VirtualColumn column) Add a column to a table.private static void
addExtendedProperties
(Element classTag, String className) Append <property> tags to the given class tag.private static void
addFilterConditions
(Element classTag, String className, HibernateUtil.FilterConfigurator filterConfig) Add <filter> conditions to the given class tag.private static void
Generate additional mappings for the raw data types.private static void
addSqlFunctions
(SessionFactoryBuilder sfBuilder, DbEngine dbEngine) Add more SQL functions to HQL that are not present in a standard Hibernate installation.private static void
addStaticMappings
(MetadataSources cfg, HibernateUtil.FilterConfigurator filterConfig) Read all mapping files, which must be namedClass.hbm.xml
where class is the name of each class.private static void
checkJdbcDriver
(String dbUrl, String dbUser, String dbPassword) Check that a JDBC driver is registered and try to load a driver if not.(package private) static void
Clear the session of cached objects.(package private) static void
Close a session.(package private) static void
close
(StatelessSession session) Close a statless session.(package private) static void
commit
(Transaction tx) Commit a transaction.private static Element
createPropertyElement
(ExtendedProperty property, Namespace ns) Creates a <property> tag from an extended property definition.(package private) static <T> Query<T>
createQuery
(Session session, String hql) Create a Hibernate query.(package private) static <R> Query<R>
createQuery
(Session session, String hql, Class<R> returnType) Create a Hibernate query with a known return type.(package private) static <R> Query<R>
createQuery
(StatelessSession session, String hql, Class<R> returnType) Create a Hibernate query using a stateless session and a known return type.(package private) static NativeQuery<?>
createSqlQuery
(Session session, String sql) Create a Hibernate SQL query.(package private) static <R> NativeQuery<R>
createSqlQuery
(Session session, String sql, Class<R> returnType) Create a Hibernate SQL query with a known return type.(package private) static NativeQuery<?>
createSqlQuery
(StatelessSession session, String sql) Create a Hibernate SQL query using a stateless session.(package private) static <R> NativeQuery<R>
createSqlQuery
(StatelessSession session, String sql, Class<R> returnType) Create a Hibernate SQL query with a known return type using a stateless session.(package private) static int
createStaticTables
(SchemaGenerator.Mode mode, ProgressReporter progress) Create the all tables in the database.(package private) static String
createVirtualTable
(VirtualDb db, VirtualTable table) Create a table in the dynamic database.static void
dbIndexes
(boolean verbose, boolean silent, boolean dropIndexes, boolean updateIndexes) Prints a lot of useful stuff about the database to standard output.private static void
defineFilter
(Element classTag, Item itemType, String name, String condition, HibernateUtil.FilterConfigurator filterConfig) Define a filter for on the given class.(package private) static void
deleteData
(Session session, BasicData data) Delete a data item from the database.(package private) static void
disableFilter
(Session session, String name) Disable the filter with the given name.(package private) static <R> R
doReturningWork
(Session session, ReturningWork<R> work) Execute some arbitrary JDBC code using the same database connection as the Hibernate session.(package private) static void
Execute some arbitrary JDBC code using the same database connection as the Hibernate session.(package private) static void
dropDynamicTable
(String tableName) (package private) static void
dropVirtualTable
(VirtualDb db, VirtualTable table) Drop a table in the dynamic database.static void
dynamicDbIndexes
(boolean verbose, boolean silent, boolean dropIndexes) Prints a lot of useful stuff about the dynamic database to standard output.(package private) static Filter
enableFilter
(Session session, String name) Enable the filter with the given name.(package private) static void
Remove a data item from the internal cache of Hibernate.(package private) static int
executeUpdate
(Query<?> query) Exceute an update or delete query.(package private) static boolean
Checks if an item with the specified ID exists in the database.private static void
fixSomeMoreThings
(Metadata metadata) Other things that we may have to fix before the final build.private static void
fixUnitSymbolColumnDefinition
(Element classTag) Fixes the definition of the UnitSymbols.symbol column so that it is case-sensitive.(package private) static void
Flush all changed objects to the database.(package private) static PersistentClass
getClassMapping
(String entityName) (package private) static Iterator<PersistentClass>
(package private) static ClassMetadata
getClassMetadata
(String entityName) (package private) static Connection
getConnection
(Session session) Get the underlying JDBC connection from the Hibernate session.private static Properties
Read database configuration properties from the base.config file and map them to Hibernate settings.static DbEngine
Get the database engine.static Dialect
Get the database dialect.static int
The number of rows to load at a time when reading from the database.(package private) static Mapping
(package private) static Connection
(package private) static Query<?>
getPredefinedQuery
(Session session, String name) Get a predefined HQL query.(package private) static <R> Query<R>
getPredefinedQuery
(Session session, String name, Class<R> returnType, String... replacements) Get a predefined HQL query with a known return type.(package private) static Query<?>
getPredefinedQuery
(Session session, String name, String... replacements) Get a predefined HQL query.(package private) static <R> Query<R>
getPredefinedQuery
(StatelessSession session, String name, Class<R> returnType) Get a predefined HQL query with a known return type using the stateless session.(package private) static <R> NativeQuery<R>
getPredefinedSQLQuery
(Session session, String name, Class<R> returnType, String... replacements) Get a predefined SQL query with a known return type.(package private) static Query<?>
getPredefinedSQLQuery
(Session session, String name, String... replacements) Get a predefined SQL query.(package private) static NativeQuery<?>
getPredefinedSQLQuery
(StatelessSession session, String name) Get a predefined SQL query using the stateless session.(package private) static <R> NativeQuery<R>
getPredefinedSQLQuery
(StatelessSession session, String name, Class<R> returnType) Get a predefined SQL query with a known return type using the stateless session.(package private) static SessionFactory
Get the configured session factory.(package private) static String
getShortEntityName
(String entityName) Removes the package name part of a class name and any ending 'Data'.(package private) static void
init1()
First step of initialising this class.(package private) static void
init2()
Second step of initialising this class.(package private) static void
initCollection
(Session session, BasicData data, String collectionName) Initialise a collection on a data object.(package private) static boolean
Check if the main database has any tables.(package private) static <T> T
Load a data item from the database using a query.(package private) static <T> T
Load a data item from the database when you know the id.(package private) static <T> T
Load a data item from the database when you know the id.(package private) static <T> T
loadData
(StatelessSession session, Class<T> clazz, int id) Load a data item from the database using a statless session when you know the id.(package private) static <T> T
loadData
(StatelessSession session, Class<T> clazz, String entityName, int id) Load a data item from the database using a statless session when you know the id.(package private) static <T> ScrollIterator<T>
loadIterator
(Query<T> query, boolean returnArray, SessionControl sc) Scroll through the result of a query using an iterator.(package private) static <T> List<T>
loadList
(Query<T> query, SessionControl sc) Load aList
of items from the database using a query.(package private) static void
lockData
(Session session, BasicData data, LockOptions lockOptions) Reconnect a disconnected data object to the session, discarding changes that have been made while the object was disconnected.private static void
manipulateDocument
(Document dom, HibernateUtil.FilterConfigurator filterConfig) Some XML files require manipulation by us before they are registered.private static Table
newDynamicMapping
(VirtualDb db, VirtualTable table, boolean withColumns) Create a neworg.hibernate.mapping.Table
object for the specified table.(package private) static Session
Create a new Hibernate session.(package private) static Session
(package private) static Session
newSession
(Interceptor interceptor, Connection c) Create a new Hibernate session, optionally with an interceptor.(package private) static StatelessSession
newStatelessSession
(Session session) (package private) static Transaction
newTransaction
(Session session) Create a new transaction for a session.static String
Quote a string with the default quote type for the current database engine.(package private) static void
Reload the data from the database for a given entity.(package private) static void
rollback
(Transaction tx) Rollback a transaction.(package private) static void
Save a new data object to the database.(package private) static void
saveData
(StatelessSession session, BasicData data) Save a new data object to the database.private static boolean
tableExists
(String tableName, Session session) Check if table in the dynamic database exists.(package private) static void
(package private) static void
unload()
Unload all settings.(package private) static BasicData
unwrapIfProxy
(Session session, BasicData data) If the given data object is a proxy, load the real data object instead.(package private) static void
updateData
(Session session, BasicData data) Update an existing data object in the database.static boolean
useThetaJoin
(QueryType queryType) Check if theta joins or ANSI joins are used by the database.(package private) static boolean
virtualTableExists
(VirtualDb db, VirtualTable table) Check if a table exists in the dynamic database or not.
-
Field Details
-
log
Log core events. -
logSql
Log all batcher SQL statements. -
sf
The single SessionFactory. -
cfg
The Hibernate configuration, including all mappings. -
metadata
The mappings related to a configuration. -
dialect
The Hibernate database dialect in use. -
dbEngine
Our extra database specific sql generation that is not possible by the Hibernate dialect. -
isInitialised
private static boolean isInitialised -
jdbcFetchSize
private static int jdbcFetchSizeNumber of rows to load at a time when iterating over a result set.- Since:
- 3.9
-
-
Constructor Details
-
HibernateUtil
public HibernateUtil()
-
-
Method Details
-
init1
First step of initialising this class. This is done at startup time by theApplication.start()
method. In this step we load configuration settings from the 'base.config' and 'hibernate.cfg.xml' files and create the Dialect and DbEngine objects. Initialising means that we load the configuration from the properties and the xml file, read all mapping files, generate additional mappings for theExtendableData
items and raw data, and generate filters used byQuery
implementation.- Throws:
BaseException
-
init2
Second step of initialising this class. This is done at startup time by theApplication.start()
method. In this step we read all mapping files, generate additional mappings for theExtendableData
items and raw data, and generate filters used byQuery
implementation.- Throws:
BaseException
-
unload
static void unload()Unload all settings. -
getConnectionProperties
Read database configuration properties from the base.config file and map them to Hibernate settings.- Returns:
- Properties for database connection
- Throws:
BaseException
- Since:
- 3.8
-
checkJdbcDriver
Check that a JDBC driver is registered and try to load a driver if not. -
addStaticMappings
private static void addStaticMappings(MetadataSources cfg, HibernateUtil.FilterConfigurator filterConfig) throws BaseException Read all mapping files, which must be namedClass.hbm.xml
where class is the name of each class. The must be located in the same directory as the class files, and we support loading the xml files both from a jar file of from the directory.- Throws:
BaseException
-
manipulateDocument
Some XML files require manipulation by us before they are registered.- Add extended properties to extendable classes
- Add filter implementation to almost all classes
- Other special-case fixes depending on the underlying database
-
addExtendedProperties
Append <property> tags to the given class tag.- Parameters:
classTag
- An Element representing a <class> tagclassName
- The name of the (ExtendableData
) class- Since:
- 2.17
-
createPropertyElement
Creates a <property> tag from an extended property definition. This also works for raw data properties since they extend from ExtendedProperty.- Since:
- 2.17
-
addFilterConditions
private static void addFilterConditions(Element classTag, String className, HibernateUtil.FilterConfigurator filterConfig) Add <filter> conditions to the given class tag.- Parameters:
classTag
- An Element representing a <class> tagclassName
- The name of the entity class- Since:
- 2.17
-
defineFilter
private static void defineFilter(Element classTag, Item itemType, String name, String condition, HibernateUtil.FilterConfigurator filterConfig) Define a filter for on the given class.- Since:
- 3.6
-
addRawDataMappings
Generate additional mappings for the raw data types.- Throws:
BaseException
-
fixSomeMoreThings
Other things that we may have to fix before the final build.- Since:
- 3.19.11
-
addSqlFunctions
Add more SQL functions to HQL that are not present in a standard Hibernate installation. SQL functions are registered on the configuration withConfiguration.addSqlFunction(String, SQLFunction)
. Note! The name of the function must be in lower-case letters, otherwise Hibernate will not be able to find it. In HQL, it is possible to use both lower-case and uppercase.Here are the functions registered so far.
- rlike: Match a string against a regular expression
- Since:
- 2.8, 3.8
-
fixUnitSymbolColumnDefinition
Fixes the definition of the UnitSymbols.symbol column so that it is case-sensitive. We need because some units have both milli (m) and Mega (M) as prefix (eg. mV and MV)- Since:
- 2.17
-
createStaticTables
static int createStaticTables(SchemaGenerator.Mode mode, ProgressReporter progress) throws BaseException Create the all tables in the database. The database must exists and we recommend that it is empty to begin with.- Returns:
- The schemaVersion that is currently installed
- Throws:
BaseException
-
isEmptyDatabase
Check if the main database has any tables.- Returns:
- TRUE if there are any tables, FALSE otherwise
- Throws:
BaseException
-
createVirtualTable
Create a table in the dynamic database. The real table name is given by theVirtualTable.getTableName(VirtualDb)
. It is assumed that the table doesn't already exists. This can be checked byvirtualTableExists(VirtualDb, VirtualTable)
. This method uses a separate connection to the database because some databases (ie. MySQL) can't handle transactions properly for this type of SQL statements.This method uses classes in the
org.hibernate.mapping
package to define a Hibernate representation of the table and uses theTable.sqlCreateString
method to generate the SQL. This should ensure that this code works with all database engines supported by Hibernate.- Parameters:
db
- The virtual db itemtable
- Information about the table to create- Returns:
- The name of the created table
- Throws:
BaseException
- See Also:
-
dropVirtualTable
Drop a table in the dynamic database. The real table name is given by theVirtualTable.getTableName(VirtualDb)
. If the table doesn't exists this method does nothing. This method uses a separate connection to the database because some databases (ie. MySQL) can't handle transactions properly for this type of SQL statements.This method uses classes in the
org.hibernate.mapping
package to define a Hibernate representation of the table and uses theTable.sqlDropString
method to generate the SQL. This should ensure that this code works with all database engines supported by Hibernate.- Parameters:
db
- The virtual db itemtable
- Information about the table to drop- Throws:
BaseException
- See Also:
-
dropDynamicTable
-
virtualTableExists
Check if a table exists in the dynamic database or not. The real table name is given by theVirtualTable.getTableName(VirtualDb)
.This method uses JDBC
DatabaseMetaData
object on a separate connection to find out if the table exists or not.- Parameters:
db
- The virtual db itemtable
- Information about the table- See Also:
-
tableExists
Check if table in the dynamic database exists.- Parameters:
tableName
- The name of the tablesession
- The Hibernate session- Throws:
SQLException
- See Also:
-
newDynamicMapping
Create a neworg.hibernate.mapping.Table
object for the specified table. This method is used bycreateVirtualTable(VirtualDb, VirtualTable)
to build the mapping information Hibernate requires to generate the SQL to create the table.- Parameters:
db
- The virtual db itemtable
- Information about the table to generate the mapping for
-
addColumn
private static void addColumn(MetadataImplementor metadata, Table hibernateTable, VirtualColumn column) Add a column to a table. This method is used bynewDynamicMapping(VirtualDb, VirtualTable, boolean)
to build the mapping information Hibernate requires to generate the SQL to create the table.- Parameters:
hibernateTable
- Theorg.hibernate.mapping.Table
object that holds the mapping for the tablecolumn
- The column to add to the table
-
getPlainConnection
- Throws:
SQLException
-
newSession
Create a new Hibernate session.- Throws:
BaseException
-
newSession
-
newSession
Create a new Hibernate session, optionally with an interceptor.- Throws:
BaseException
- Since:
- 2.13
-
newStatelessSession
- Throws:
BaseException
-
newTransaction
Create a new transaction for a session. If a transaction has already been created for the session, that one is returned.- Throws:
BaseException
-
getConnection
Get the underlying JDBC connection from the Hibernate session. Hibernate 3.3 have implemented a partial replacement for the Session.connection() method that can be used if the connection or any derived object such as a PreparedStatement or ResultSet is not needed after the connection has been used. Such code should usedoWork(Session, Work)
instead.Other code may continue using this method until the Hibernate team develops a full replacement. See http://forum.hibernate.org/viewtopic.php?t=974518
- Since:
- 2.4
- See Also:
-
getSessionFactory
Get the configured session factory.- Since:
- 2.15
-
doWork
Execute some arbitrary JDBC code using the same database connection as the Hibernate session. This method should be used instead ofgetConnection(Session)
wherever possible.- Parameters:
session
- The Hibernate session to usework
- The work implementation- Throws:
SQLException
- In case there is an SQL error- Since:
- 3.4
-
doReturningWork
Execute some arbitrary JDBC code using the same database connection as the Hibernate session. This method should be used instead ofgetConnection(Session)
wherever possible.- Parameters:
session
- The Hibernate session to usework
- The work implementation- Returns:
- Determined by the work implementation
- Throws:
SQLException
- In case there is an SQL error- Since:
- 3.4
-
commit
Commit a transaction.- Throws:
BaseException
-
rollback
Rollback a transaction.- Throws:
BaseException
-
close
Close a session. -
close
Close a statless session. -
flush
Flush all changed objects to the database.- Throws:
BaseException
- See Also:
-
clear
Clear the session of cached objects. Changes that has not been written to the database are lost.- Throws:
BaseException
- See Also:
-
saveData
Save a new data object to the database.- Throws:
BaseException
-
saveData
Save a new data object to the database.- Throws:
BaseException
-
updateData
Update an existing data object in the database.- Throws:
BaseException
-
lockData
Reconnect a disconnected data object to the session, discarding changes that have been made while the object was disconnected. This method is most useful withlockOptions
=LockOptions.NONE
if the logged in user only has read permission to the object.- Throws:
BaseException
- See Also:
-
loadData
Load a data item from the database when you know the id.- Parameters:
session
- The Hibernate session which is connected to the databaseclazz
- An object of this class is returned with the dataid
- The id of the item to load- Throws:
BaseException
-
loadData
static <T> T loadData(Session session, Class<T> clazz, String entityName, int id) throws BaseException Load a data item from the database when you know the id.- Parameters:
session
- The Hibernate session which is connected to the databaseclazz
- An object of this class is returned with the dataentityName
- The entity name of the itemid
- The id of the item to load- Throws:
BaseException
- Since:
- 2.15
-
refresh
Reload the data from the database for a given entity.- Parameters:
session
- The Hibernate session which is connected to the databasedata
- The entity to reload- Since:
- 2.4
-
unwrapIfProxy
If the given data object is a proxy, load the real data object instead.- Since:
- 3.3.3
-
exists
Checks if an item with the specified ID exists in the database.- Parameters:
session
- The Hibernate session which is connected to the databaseclazz
- The type of the itemid
- The ID of the item- Returns:
- TRUE if the item exists in the database, FALSE otherwise
- Since:
- 2.4
-
loadData
Load a data item from the database using a statless session when you know the id.- Parameters:
session
- The Hibernate stateless session which is connected to the databaseclazz
- An object of this class is returned with the dataid
- The id of the item to load- Throws:
BaseException
-
loadData
static <T> T loadData(StatelessSession session, Class<T> clazz, String entityName, int id) throws BaseException Load a data item from the database using a statless session when you know the id.- Parameters:
session
- The Hibernate stateless session which is connected to the databaseclazz
- An object of this class is returned with the dataentityName
- The entity name of the itemid
- The id of the item to load- Throws:
BaseException
-
loadData
Load a data item from the database using a query. If the query returns more than one item, only the first is returned.- Parameters:
query
- AQuery
object which should select one item of the specified class- Throws:
BaseException
-
executeUpdate
Exceute an update or delete query.- Parameters:
query
- AQuery
object which is executed using theQuery.executeUpdate()
method- Returns:
- The number of affected items
- Throws:
BaseException
-
initCollection
static void initCollection(Session session, BasicData data, String collectionName) throws BaseException Initialise a collection on a data object. This method is useful if you plan to detach an item.- Throws:
BaseException
- See Also:
-
deleteData
Delete a data item from the database. If the ID doesn't exist in the database this metod does nothing.- Throws:
BaseException
-
evictData
Remove a data item from the internal cache of Hibernate. This also means that changes to the object will not be saved to the database unless it is reconnected again. -
createQuery
Create a Hibernate query.- Throws:
BaseException
-
createQuery
static <R> Query<R> createQuery(Session session, String hql, Class<R> returnType) throws BaseException Create a Hibernate query with a known return type.- Throws:
BaseException
- Since:
- 3.12
-
createQuery
static <R> Query<R> createQuery(StatelessSession session, String hql, Class<R> returnType) throws BaseException Create a Hibernate query using a stateless session and a known return type.- Throws:
BaseException
- Since:
- 3.12
-
createSqlQuery
Create a Hibernate SQL query.- Throws:
BaseException
-
createSqlQuery
static <R> NativeQuery<R> createSqlQuery(Session session, String sql, Class<R> returnType) throws BaseException Create a Hibernate SQL query with a known return type.- Throws:
BaseException
- Since:
- 3.12
-
createSqlQuery
Create a Hibernate SQL query using a stateless session.- Throws:
BaseException
-
createSqlQuery
static <R> NativeQuery<R> createSqlQuery(StatelessSession session, String sql, Class<R> returnType) throws BaseException Create a Hibernate SQL query with a known return type using a stateless session.- Throws:
BaseException
- Since:
- 3.12
-
enableFilter
Enable the filter with the given name.- Throws:
BaseException
-
disableFilter
Disable the filter with the given name.- Throws:
BaseException
-
loadList
Load aList
of items from the database using a query.- Parameters:
query
- The query to executesc
- A optional SessionControl that is automatically protected from timeouts during the time the query is running- Throws:
BaseException
-
loadIterator
static <T> ScrollIterator<T> loadIterator(Query<T> query, boolean returnArray, SessionControl sc) throws BaseException Scroll through the result of a query using an iterator.- Parameters:
query
- The query to executesc
- A optional SessionControl that is automatically protected from timeouts during the time the query is running- Throws:
BaseException
- Since:
- 3.12
-
getPredefinedQuery
Get a predefined HQL query.- Throws:
BaseException
- See Also:
-
getPredefinedQuery
static Query<?> getPredefinedQuery(Session session, String name, String... replacements) throws BaseException Get a predefined HQL query.- Parameters:
replacements
- In the SQL string we look for {1}, {2}, ... and replace this with the contents of the string array- Throws:
BaseException
- See Also:
-
getPredefinedQuery
static <R> Query<R> getPredefinedQuery(Session session, String name, Class<R> returnType, String... replacements) throws BaseException Get a predefined HQL query with a known return type.- Parameters:
replacements
- In the SQL string we look for {1}, {2}, ... and replace this with the contents of the string array- Throws:
BaseException
- Since:
- 3.12
- See Also:
-
getPredefinedQuery
static <R> Query<R> getPredefinedQuery(StatelessSession session, String name, Class<R> returnType) throws BaseException Get a predefined HQL query with a known return type using the stateless session.- Throws:
BaseException
- Since:
- 3.12
- See Also:
-
getPredefinedSQLQuery
static Query<?> getPredefinedSQLQuery(Session session, String name, String... replacements) throws BaseException Get a predefined SQL query.- Throws:
BaseException
- See Also:
-
getPredefinedSQLQuery
static <R> NativeQuery<R> getPredefinedSQLQuery(Session session, String name, Class<R> returnType, String... replacements) throws BaseException Get a predefined SQL query with a known return type.- Throws:
BaseException
- Since:
- 3.12
- See Also:
-
getPredefinedSQLQuery
static NativeQuery<?> getPredefinedSQLQuery(StatelessSession session, String name) throws BaseException Get a predefined SQL query using the stateless session.- Throws:
BaseException
- See Also:
-
getPredefinedSQLQuery
static <R> NativeQuery<R> getPredefinedSQLQuery(StatelessSession session, String name, Class<R> returnType) throws BaseException Get a predefined SQL query with a known return type using the stateless session.- Throws:
BaseException
- See Also:
-
getClassMappings
-
getClassMapping
-
getClassMetadata
-
getMapping
-
getDialect
Get the database dialect. -
getDbEngine
Get the database engine. -
getJdbcFetchSize
public static int getJdbcFetchSize()The number of rows to load at a time when reading from the database.- Since:
- 3.9
-
useThetaJoin
Check if theta joins or ANSI joins are used by the database.- Parameters:
queryType
- Query type to be checked.- Returns:
- TRUE if theta joins are used, FALSE if ANSI joins are used.
-
quote
Quote a string with the default quote type for the current database engine. Ie. with MySQL:value --> `value`
, and with any ANSI-compatible database:value --> "value"
. This method uses theDialect.openQuote
andDialect.closeQuote
methods of the currently installed Hibernate dialect.- Parameters:
value
- The value to quote- Returns:
- The quoted value
- See Also:
-
getShortEntityName
Removes the package name part of a class name and any ending 'Data'. -
testTransactions
- Throws:
BaseException
-
dynamicDbIndexes
public static void dynamicDbIndexes(boolean verbose, boolean silent, boolean dropIndexes) Prints a lot of useful stuff about the dynamic database to standard output. For each table the output includes information about columns, indexes, primary keys and foreign keys as found in the current database.- Parameters:
verbose
- If true, lots of information will be printedsilent
- If true, no information will be printeddropIndexes
- If true, all indexes will be dropped
-
dbIndexes
public static void dbIndexes(boolean verbose, boolean silent, boolean dropIndexes, boolean updateIndexes) Prints a lot of useful stuff about the database to standard output. For each table the output includes information about columns, indexes, primary keys and foreign keys as found in the Hibernate mapping information and in the current database.- Parameters:
verbose
- If true, lots of information will be printedsilent
- If true, no information will be printeddropIndexes
- If true, all indexes will be droppedupdateIndexes
- If true, indexes that doesn't already exist will be created
-