Package com.logicaldoc.core
Interface PersistentObjectDAO<T extends PersistentObject>
- Type Parameters:
- T- Class of the implementation of a- PersistentObjectthis DAO handles
- All Known Subinterfaces:
- ApiKeyDAO,- AttributeOptionDAO,- AttributeSetDAO,- BookmarkDAO,- ContactDAO,- DashletDAO,- DeviceDAO,- DocumentDAO,- DocumentHistoryDAO,- DocumentLinkDAO,- DocumentNoteDAO,- FolderDAO,- FolderHistoryDAO,- GenericDAO,- GroupDAO,- MenuDAO,- MessageTemplateDAO,- PasswordHistoryDAO,- RatingDAO,- SearchDAO,- SequenceDAO,- SessionDAO,- SystemMessageDAO,- TemplateDAO,- TenantDAO,- TicketDAO,- UserDAO,- UserHistoryDAO,- VersionDAO,- WebserviceCallDAO
- All Known Implementing Classes:
- HibernateApiKeyDAO,- HibernateAttributeOptionDAO,- HibernateAttributeSetDAO,- HibernateBookmarkDAO,- HibernateContactDAO,- HibernateDashletDAO,- HibernateDeviceDAO,- HibernateDocumentDAO,- HibernateDocumentHistoryDAO,- HibernateDocumentLinkDAO,- HibernateDocumentNoteDAO,- HibernateFolderDAO,- HibernateFolderHistoryDAO,- HibernateGenericDAO,- HibernateGroupDAO,- HibernateHistoryDAO,- HibernateMenuDAO,- HibernateMessageTemplateDAO,- HibernatePasswordHistoryDAO,- HibernatePersistentObjectDAO,- HibernateRatingDAO,- HibernateSearchDAO,- HibernateSequenceDAO,- HibernateSessionDAO,- HibernateSystemMessageDAO,- HibernateTemplateDAO,- HibernateTenantDAO,- HibernateTicketDAO,- HibernateUserDAO,- HibernateUserHistoryDAO,- HibernateVersionDAO,- HibernateWebserviceCallDAO
public interface PersistentObjectDAO<T extends PersistentObject>
Interface for DAOs that operate on persistent objects
- Since:
- 4.0
- Author:
- Marco Meschieri - LogicalDOC
- 
Field SummaryFields
- 
Method SummaryModifier and TypeMethodDescriptionintbulkUpdate(String expression, Map<String, Object> parameters) Executes a bulk update as specified by the given HQL 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 codevoidevict(long id) Removes an entity from current session and cachevoidevict(Class<? extends PersistentObject> obj, long id) Removes an entity from current session and cachefindAll()Finds all entities in the databasefindAll(long tenantId) Finds all entities in a specific tenant.Finds all entities idsfindAllIds(long tenantId) Finds all entities ids in a specific tenant.findById(long id) This method finds an entity by IDfindById(long id, boolean initialize) This method finds an entity by IDFinds all entities by the given object query.<R> List<R> Find everything you want from the DB using the ORM query languageFind everything you want from the DB using the ORM query languagefindByWhere(String where, String order, Integer max) Finds all entities by the given expression.Finds all entities by the given expression.findIdsByWhere(String where, String order, Integer max) Finds all entities ids by the given expression.Finds all entities ids by the given expression.Retrieves the metadata from the databasegetDbms()Get the DBMS name currently connected(possible values are: mysql, mariadb, postgresql, hsqldb, oracle, mssql)voidinitialize(T entity) Initialises lazy loaded data such as collectionsbooleanisMySQL()booleanisOracle()intjdbcUpdate(String sql) Executes the given SQL update statementintjdbcUpdate(String sql, Map<String, Object> parameters) Issue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments<P> List<P> query(String sql, Map<String, Object> parameters, org.springframework.jdbc.core.RowMapper<P> 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.<P> List<P> 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.doublequeryForDouble(String sql) Execute a query that results in a double value, given static SQL.doublequeryForDouble(String sql, Map<String, Object> parameters) Execute a query that results in a double value, given static SQL.intqueryForInt(String sql) Execute a query that results in an int value, given static SQL.intqueryForInt(String sql, Map<String, Object> parameters) Execute a query that results in an int value, given static SQL.<R> List<R> queryForList(String sql, Class<R> requiredType) Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.<R> List<R> queryForList(String sql, Class<R> requiredType, Integer maxRows) Execute a query for a result list, given static SQL.<R> List<R> 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, Map<String, Object> parameters) Execute a query that results in an long value, given static SQL.<R> RqueryForObject(String sql, Class<R> requiredType) Execute a query that results in a Object value, given static SQL.<R> RExecute a query that results in a Object value, given static SQL.voidqueryForResultSet(String sql, Map<String, Object> parameters, Integer maxRows, ResultSetWalker worker) Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, you can give your own worker to iterate theResultSet.queryForString(String sql) Execute a query that results in an string value, given static SQL.queryForString(String sql, Map<String, Object> parameters) Execute a query that results in an string value, given static SQL.voidThis method persists the entity object
- 
Field Details- 
ENTITYThe alias to use to reference the object in the queries- See Also:
 
 
- 
- 
Method Details- 
storeThis method persists the entity object- Parameters:
- entity- entity to be stored
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
findByIdThis method finds an entity by ID- Parameters:
- id- ID of the entity
- Returns:
- Entity with given ID
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
findByIdThis method finds an entity by ID- 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
 
- 
findAllFinds all entities in the database- Returns:
- The list of all entities
- Throws:
- PersistenceException- Error in the database
 
- 
findAllFinds all entities in a specific tenant.- Parameters:
- tenantId- Identifier of the tenant to search in
- Returns:
- The list of all entities
- Throws:
- PersistenceException- Error in the database
 
- 
findAllIdsFinds all entities ids- Returns:
- The list of all entities ids
- Throws:
- PersistenceException- Error in the database
 
- 
findAllIdsFinds all entities ids in a specific tenant.- Parameters:
- tenantId- Identifier of the tenant to search in
- Returns:
- The list of all entities ids
- Throws:
- PersistenceException- Error in the database
 
- 
findByWhereFinds all entities by the given expression. Use "_entity"<T extends PersistentObject> alias to reference attributes in the where expression.- 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
 
- 
findByWhereList<T> findByWhere(String where, Map<String, Object> parameters, String order, Integer max) throws PersistenceExceptionFinds all entities by the given expression. Use "_entity"<T extends PersistentObject> alias to reference attributes in the where expression.- 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
 
- 
findByObjectQueryList<T> findByObjectQuery(String query, Map<String, Object> parameters, Integer max) throws PersistenceExceptionFinds all entities by the given object query.- 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
 
- 
findByQueryList<Object[]> findByQuery(String query, Map<String, Object> parameters, Integer max) throws PersistenceExceptionFind everything you want from the DB using the ORM query language- 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
 
- 
findByQuery<R> List<R> findByQuery(String query, Map<String, Object> parameters, Class<R> requiredType, Integer max) throws PersistenceExceptionFind everything you want from the DB using the ORM query language- Parameters:
- query- The query to execute
- parameters- The map of the parameters
- requiredType- The type of the elements in the result
- max- Maximum results number (optional)
- Returns:
- Query result
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
findIdsByWhereFinds all entities ids by the given expression. Use "_entity"<T extends PersistentObject> alias to reference attributes in the where expression.- 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
 
- 
findIdsByWhereList<Long> findIdsByWhere(String where, Map<String, Object> parameters, String order, Integer max) throws PersistenceExceptionFinds all entities ids by the given expression. Use "_entity"<T extends PersistentObject> alias to reference attributes in the where expression.- Parameters:
- where- The where clause expression (for parameters, please use JPA-style: :paramA, :paramB ...)
- parameters- The map of the parameters
- 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
 
- 
initializeInitialises lazy loaded data such as collections- Parameters:
- entity- The entity to be initialised
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
query<P> List<P> query(String sql, org.springframework.jdbc.core.RowMapper<P> rowMapper, Integer maxRows) throws PersistenceException 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.- Parameters:
- sql- SQL query to execute
- 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
 
- 
query<P> List<P> query(String sql, Map<String, Object> parameters, org.springframework.jdbc.core.RowMapper<P> rowMapper, Integer maxRows) throws PersistenceExceptionQuery 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.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- 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
 
- 
queryForResultSetvoid queryForResultSet(String sql, Map<String, Object> parameters, Integer maxRows, ResultSetWalker worker) throws PersistenceExceptionQuery given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, you can give your own worker to iterate theResultSet.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- maxRows- the new max rows limit; null means there is no limit
- worker- an implementation that receive the- ResultSetto iterate
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForList<R> List<R> queryForList(String sql, Map<String, Object> parameters, Class<R> requiredType, Integer maxRows) throws PersistenceExceptionQuery 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.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- requiredType- 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
 
- 
queryForList<R> List<R> queryForList(String sql, Class<R> requiredType, Integer maxRows) throws PersistenceException Execute 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.- Parameters:
- sql- SQL query to execute
- requiredType- 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
 
- 
queryForListQuery 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.- Parameters:
- sql- SQL query to execute
- requiredType- 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
 
- 
queryForIntExecute 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.- 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
 
- 
queryForIntExecute 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.- Parameters:
- sql- SQL query to execute
- parameters- Parameters used in the where expression (map name-value)
- Returns:
- the int value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForLongExecute 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.- 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
 
- 
queryForLongExecute 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.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- Returns:
- the long value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForDoubleExecute a query that results in a double 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.- Parameters:
- sql- SQL query to execute
- Returns:
- the double value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForDoubleExecute a query that results in a double 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.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- Returns:
- the double value, or 0 in case of SQL NULL
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForStringExecute 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.- Parameters:
- sql- SQL query to execute
- Returns:
- the string value
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForStringExecute 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.- Parameters:
- sql- SQL query to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- Returns:
- the string value
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForObjectExecute 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.- Parameters:
- sql- SQL query to execute
- requiredType- The type of the returned value
- Returns:
- the object value
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
queryForObject<R> R queryForObject(String sql, Map<String, Object> parameters, Class<R> requiredType) throws PersistenceExceptionExecute 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.- Parameters:
- sql- SQL query to execute
- parameters- Optional map of parameters
- requiredType- The type of the returned value
- Returns:
- the object value
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
deleteThis method deletes an entity. Same as delete(id, 1)- Parameters:
- id- ID of the entity which should be deleted.
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
deleteThis method deletes an entity and you can give a deletion code- Parameters:
- id- ID of the entity which should be deleted
- code- Deletion code
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
deleteAllDeletes all entries form the database- Parameters:
- entities- The entities to be deleted
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
deleteAllDeletes all entries form the database giving a specific deletion code- Parameters:
- entities- The entities to be deleted
- code- The deletion code
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
evictRemoves an entity from current session and cache- Parameters:
- obj- Class of the entity to evict
- id- Identifier of the entity
 
- 
evictvoid evict(long id) Removes an entity from current session and cache- Parameters:
- id- Identifier of the entity
 
- 
bulkUpdateExecutes a bulk update as specified by the given HQL expression- 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
 
- 
jdbcUpdateExecutes the given SQL update statement- Parameters:
- sql- 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
 
- 
jdbcUpdateIssue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments- Parameters:
- sql- SQL statement to execute (for parameters please use JPA-style: :paramA, :paramB ...)
- parameters- Parameters used in the where expression (map name-value)
- Returns:
- the number of rows affected
- Throws:
- PersistenceException- raised in case of errors in the database
 
- 
getDbmsString getDbms()Get the DBMS name currently connected(possible values are: mysql, mariadb, postgresql, hsqldb, oracle, mssql)- Returns:
- the database identifier
 
- 
isOracleboolean isOracle()
- 
isMySQLboolean isMySQL()
- 
getDatabaseMetadataRetrieves the metadata from the database- Returns:
- a map of metadata from the database driver
 
 
-