Package com.logicaldoc.core
Class HibernatePersistentObjectDAO<T extends PersistentObject>
- java.lang.Object
- 
- com.logicaldoc.core.HibernatePersistentObjectDAO<T>
 
- 
- All Implemented Interfaces:
- PersistentObjectDAO<T>
 - Direct Known Subclasses:
- HibernateAttributeOptionDAO,- HibernateAttributeSetDAO,- HibernateBookmarkDAO,- HibernateContactDAO,- HibernateDashletDAO,- HibernateDeviceDAO,- HibernateDocumentDAO,- HibernateDocumentHistoryDAO,- HibernateDocumentLinkDAO,- HibernateDocumentNoteDAO,- HibernateFolderDAO,- HibernateFolderHistoryDAO,- HibernateGenericDAO,- HibernateGroupDAO,- HibernateMenuDAO,- HibernateMessageTemplateDAO,- HibernatePasswordHistoryDAO,- HibernateRatingDAO,- HibernateSearchDAO,- HibernateSequenceDAO,- HibernateSessionDAO,- HibernateSystemMessageDAO,- HibernateTemplateDAO,- HibernateTenantDAO,- HibernateTicketDAO,- HibernateUserDAO,- HibernateUserHistoryDAO,- HibernateVersionDAO,- HibernateWebserviceCallDAO
 
 public abstract class HibernatePersistentObjectDAO<T extends PersistentObject> extends Object implements PersistentObjectDAO<T> Hibernate implementation ofPersistentObjectDAO- Since:
- 4.0
- Author:
- Marco Meschieri - LogicalDOC
 
- 
- 
Field Summary- 
Fields inherited from interface com.logicaldoc.core.PersistentObjectDAOENTITY
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intbulkUpdate(String expression, Object[] values)Executes a bulk update as specified by the given expressionintbulkUpdate(String expression, Map<String,Object> parameters)Executes a bulk update as specified by the given expressionvoiddelete(long id)This method deletes an entity.voiddelete(long id, int code)This method deletes an entity and you can give a deletion codevoiddeleteAll(Collection<T> entities)Deletes all entries form the databasevoiddeleteAll(Collection<T> entities, int code)Deletes all entries form the database giving a specific deletion codeList<T>findAll()Finds all entities in the databaseList<T>findAll(long tenantId)Finds all entities in a specific tenant.List<Long>findAllIds()Finds all entities idsList<Long>findAllIds(long tenantId)Finds all entities ids in a specific tenant.TfindById(long id)This method finds an entity by IDTfindById(long id, boolean initialize)This method finds an entity by IDList<T>findByObjectQuery(String query, Object[] values, Integer max)Finds all entities by the given object query.List<T>findByObjectQuery(String query, Map<String,Object> parameters, Integer max)Finds all entities by the given object query.ListfindByQuery(String query, Object[] values, Integer max)Find everything you want from the DB using the ORM query languageListfindByQuery(String query, Map<String,Object> parameters, Integer max)Find everything you want from the DB using the ORM query languageList<T>findByWhere(String where, Object[] values, String order, Integer max)Finds all entities by the given expression.List<T>findByWhere(String where, String order, Integer max)Finds all entities by the given expression.List<T>findByWhere(String where, Map<String,Object> parameters, String order, Integer max)Finds all entities by the given expression.List<Long>findIdsByWhere(String where, Object[] values, String order, Integer max)Finds all entities ids by the given expression.List<Long>findIdsByWhere(String where, String order, Integer max)Finds all entities ids by the given expression.StringgetDbms()Get the DBMS name currently connected(possible values are: mysql, hsqldb, oracle, mssql)org.hibernate.SessionFactorygetSessionFactory()voidinitialize(T entity)Doesn't do anything by defaultbooleanisOracle()intjdbcUpdate(String statement)Executes the given SQL update statementintjdbcUpdate(String statement, Object... args)Issue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given argumentsListquery(String sql, Object[] args, org.springframework.jdbc.core.RowMapper rowMapper, Integer maxRows)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper.intqueryForInt(String sql)Execute a query that results in an int value, given static SQL.ListqueryForList(String sql, Class elementType)Execute a query for a result list, given static SQL.ListqueryForList(String sql, Object[] args, Class elementType, Integer maxRows)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.longqueryForLong(String sql)Execute a query that results in an long value, given static SQL.longqueryForLong(String sql, Object... args)Execute a query that results in an long value, given static SQL.ObjectqueryForObject(String sql, Class type)Execute a query that results in a Object value, given static SQL.org.springframework.jdbc.support.rowset.SqlRowSetqueryForRowSet(String sql, Object[] args, Integer maxRows)Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, returns a navigable RowSetStringqueryForString(String sql)Execute a query that results in an string value, given static SQL.voidsetSessionFactory(org.hibernate.SessionFactory sessionFactory)voidstore(T entity)This method persists the entity object
 
- 
- 
- 
Method Detail- 
setSessionFactorypublic void setSessionFactory(org.hibernate.SessionFactory sessionFactory) 
 - 
deletepublic void delete(long id, int code) throws PersistenceExceptionDescription copied from interface:PersistentObjectDAOThis method deletes an entity and you can give a deletion code- Specified by:
- deletein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- id- ID of the entity which should be deleted
- code- Deletion code
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
deletepublic void delete(long id) throws PersistenceExceptionDescription copied from interface:PersistentObjectDAOThis method deletes an entity. Same as delete(id, 1)- Specified by:
- deletein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- id- ID of the entity which should be deleted.
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findAllpublic List<T> findAll() Description copied from interface:PersistentObjectDAOFinds all entities in the database- Specified by:
- findAllin interface- PersistentObjectDAO<T extends PersistentObject>
- Returns:
- The list of all entities
 
 - 
findAllpublic List<T> findAll(long tenantId) Description copied from interface:PersistentObjectDAOFinds all entities in a specific tenant.- Specified by:
- findAllin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- tenantId- Identifier of the tenant to search in
- Returns:
- The list of all entities
 
 - 
findAllIdspublic List<Long> findAllIds() Description copied from interface:PersistentObjectDAOFinds all entities ids- Specified by:
- findAllIdsin interface- PersistentObjectDAO<T extends PersistentObject>
- Returns:
- The list of all entities ids
 
 - 
findAllIdspublic List<Long> findAllIds(long tenantId) Description copied from interface:PersistentObjectDAOFinds all entities ids in a specific tenant.- Specified by:
- findAllIdsin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- tenantId- Identifier of the tenant to search in
- Returns:
- The list of all entities ids
 
 - 
findByIdpublic T findById(long id, boolean initialize) throws PersistenceException Description copied from interface:PersistentObjectDAOThis method finds an entity by ID- Specified by:
- findByIdin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- id- ID of the entity
- initialize- True if the instance's lazy collections have to be initialized
- Returns:
- Entity with given ID
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByIdpublic T findById(long id) throws PersistenceException Description copied from interface:PersistentObjectDAOThis method finds an entity by ID- Specified by:
- findByIdin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- id- ID of the entity
- Returns:
- Entity with given ID
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByWherepublic List<T> findByWhere(String where, String order, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Specified by:
- findByWherein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- where- The where clause expression
- order- The order clause expression
- max- Maximum results number (optional)
- Returns:
- The list of marching entities
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByWherepublic List<T> findByWhere(String where, Object[] values, String order, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Specified by:
- findByWherein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- where- The where clause expression
- values- Parameters used in the where expression
- order- The order clause expression
- max- Maximum results number (optional)
- Returns:
- The list of marching entities
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByObjectQuerypublic List<T> findByObjectQuery(String query, Object[] values, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities by the given object query.- Specified by:
- findByObjectQueryin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- query- The query expression (for positional parameters, please use JPA-style: ?1, ?2 ...)
- values- Parameters used in the where expression
- max- Maximum results number (optional)
- Returns:
- The list of matching entities
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByWherepublic List<T> findByWhere(String where, Map<String,Object> parameters, String order, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Specified by:
- findByWherein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- where- The where clause expression
- parameters- Parameters used in the where expression
- order- The order clause expression
- max- Maximum results number (optional)
- Returns:
- The list of marching entities
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByObjectQuerypublic List<T> findByObjectQuery(String query, Map<String,Object> parameters, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities by the given object query.- Specified by:
- findByObjectQueryin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- query- The query expression
- parameters- Parameters used in the where expression
- max- Maximum results number (optional)
- Returns:
- The list of matching entities
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByQuerypublic List findByQuery(String query, Object[] values, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFind everything you want from the DB using the ORM query language- Specified by:
- findByQueryin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- query- The query to execute (for positional parameters, please use JPA-style: ?1, ?2 ...)
- values- Array of paramaters
- max- Maximum results number (optional)
- Returns:
- Query result
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findByQuerypublic List findByQuery(String query, Map<String,Object> parameters, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFind everything you want from the DB using the ORM query language- Specified by:
- findByQueryin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- query- The query to execute
- parameters- The map of the parameters
- max- Maximum results number (optional)
- Returns:
- Query result
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findIdsByWherepublic List<Long> findIdsByWhere(String where, String order, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities ids by the given expression. Use "_entity" alias to reference attributes in the where expression.- Specified by:
- findIdsByWherein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- where- The where clause expression
- order- The order clause expression
- max- Maximum results number (optional)
- Returns:
- The list of marching entities ids
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
findIdsByWherepublic List<Long> findIdsByWhere(String where, Object[] values, String order, Integer max) throws PersistenceException Description copied from interface:PersistentObjectDAOFinds all entities ids by the given expression. Use "_entity" alias to reference attributes in the where expression.- Specified by:
- findIdsByWherein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- where- The where clause expression (for positional parameters, please use JPA-style: ?1, ?2 ...)
- values- Parameters used in the where expression
- order- The order clause expression
- max- Maximum results number (optional)
- Returns:
- The list of marching entities ids
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
storepublic void store(T entity) throws PersistenceException Description copied from interface:PersistentObjectDAOThis method persists the entity object- Specified by:
- storein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- entity- entity to be stored
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
initializepublic void initialize(T entity) Doesn't do anything by default- Specified by:
- initializein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- entity- The entity to be initialised
 
 - 
querypublic List query(String sql, Object[] args, org.springframework.jdbc.core.RowMapper rowMapper, Integer maxRows) throws PersistenceException Description copied from interface:PersistentObjectDAOQuery given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, mapping each row to a Java object via a RowMapper.- Specified by:
- queryin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- args- arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
- rowMapper- object that will map one object per row
- maxRows- the new max rows limit; null means there is no limit
- Returns:
- the result List, containing mapped objects
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForListpublic List queryForList(String sql, Object[] args, Class elementType, Integer maxRows) throws PersistenceException Description copied from interface:PersistentObjectDAOQuery given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list. The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.- Specified by:
- queryForListin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- args- arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
- elementType- the required type of element in the result list (for example, Integer.class)
- maxRows- maximum number of returned records
- Returns:
- a List of objects that match the specified element type
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForRowSetpublic org.springframework.jdbc.support.rowset.SqlRowSet queryForRowSet(String sql, Object[] args, Integer maxRows) throws PersistenceException Description copied from interface:PersistentObjectDAOQuery given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, returns a navigable RowSet- Specified by:
- queryForRowSetin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- args- arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
- maxRows- the new max rows limit; null means there is no limit
- Returns:
- the result row set
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForListpublic List queryForList(String sql, Class elementType) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query for a result list, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForList method with null as argument array. The results will be mapped to a List (one entry for each row) of result objects, each of them matching the specified element type.- Specified by:
- queryForListin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- elementType- the required type of element in the result list (for example, Integer.class)
- Returns:
- a List of objects that match the specified element type
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForIntpublic int queryForInt(String sql) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query that results in an int value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in an int value.- Specified by:
- queryForIntin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- Returns:
- the int value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForLongpublic long queryForLong(String sql) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query that results in an long value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a long value.- Specified by:
- queryForLongin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- Returns:
- the long value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForLongpublic long queryForLong(String sql, Object... args) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query that results in an long value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a long value.- Specified by:
- queryForLongin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- args- arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
- Returns:
- the long value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForStringpublic String queryForString(String sql) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query that results in an string value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement, use the overloaded queryForInt method with null as argument array. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a string value.- Specified by:
- queryForStringin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- Returns:
- the string value
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
queryForObjectpublic Object queryForObject(String sql, Class type) throws PersistenceException Description copied from interface:PersistentObjectDAOExecute a query that results in a Object value, given static SQL. Uses a JDBC Statement, not a PreparedStatement. If you want to execute a static query with a PreparedStatement. This method is useful for running static SQL with a known outcome. The query is expected to be a single row/single column query that results in a object value.- Specified by:
- queryForObjectin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- sql- SQL query to execute
- type- The type of the returned value
- Returns:
- the object value
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
jdbcUpdatepublic int jdbcUpdate(String statement) throws PersistenceException Description copied from interface:PersistentObjectDAOExecutes the given SQL update statement- Specified by:
- jdbcUpdatein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- statement- the SQL statement to execute against the database
- Returns:
- the value returned by the database after execution
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
deleteAllpublic void deleteAll(Collection<T> entities, int code) throws PersistenceException Description copied from interface:PersistentObjectDAODeletes all entries form the database giving a specific deletion code- Specified by:
- deleteAllin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- entities- The entities to be deleted
- code- The deletion code
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
deleteAllpublic void deleteAll(Collection<T> entities) throws PersistenceException Description copied from interface:PersistentObjectDAODeletes all entries form the database- Specified by:
- deleteAllin interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- entities- The entities to be deleted
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
bulkUpdatepublic int bulkUpdate(String expression, Object[] values) throws PersistenceException Description copied from interface:PersistentObjectDAOExecutes a bulk update as specified by the given expression- Specified by:
- bulkUpdatein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- expression- The update expression. (for positional parameters, please use JPA-style: ?1, ?2 ...)
- values- Optional array of parameters values
- Returns:
- the number of modified records
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
bulkUpdatepublic int bulkUpdate(String expression, Map<String,Object> parameters) throws PersistenceException Description copied from interface:PersistentObjectDAOExecutes a bulk update as specified by the given expression- Specified by:
- bulkUpdatein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- expression- The update expression.
- parameters- Optional map of parameters
- Returns:
- the number of modified records
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
jdbcUpdatepublic int jdbcUpdate(String statement, Object... args) throws PersistenceException Description copied from interface:PersistentObjectDAOIssue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments- Specified by:
- jdbcUpdatein interface- PersistentObjectDAO<T extends PersistentObject>
- Parameters:
- statement- SQL containing bind parameters
- args- arguments to bind to the query (leaving it to the PreparedStatement to guess the corresponding SQL type); may also contain SqlParameterValue objects which indicate not only the argument value but also the SQL type and optionally the scale
- Returns:
- the number of rows affected
- Throws:
- PersistenceException- raised in case of errors in the database
 
 - 
getDbmspublic String getDbms() Description copied from interface:PersistentObjectDAOGet the DBMS name currently connected(possible values are: mysql, hsqldb, oracle, mssql)- Specified by:
- getDbmsin interface- PersistentObjectDAO<T extends PersistentObject>
- Returns:
- the database identifier
 
 - 
isOraclepublic boolean isOracle() - Specified by:
- isOraclein interface- PersistentObjectDAO<T extends PersistentObject>
 
 - 
getSessionFactorypublic org.hibernate.SessionFactory getSessionFactory() 
 
- 
 
-