Package com.logicaldoc.core
Interface PersistentObjectDAO<T extends PersistentObject>
-
- All Known Subinterfaces:
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:
HibernateAttributeOptionDAO
,HibernateAttributeSetDAO
,HibernateBookmarkDAO
,HibernateContactDAO
,HibernateDashletDAO
,HibernateDeviceDAO
,HibernateDocumentDAO
,HibernateDocumentHistoryDAO
,HibernateDocumentLinkDAO
,HibernateDocumentNoteDAO
,HibernateFolderDAO
,HibernateFolderHistoryDAO
,HibernateGenericDAO
,HibernateGroupDAO
,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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description int
bulkUpdate(String expression, Object[] values)
Deprecated.int
bulkUpdate(String expression, Map<String,Object> parameters)
Executes a bulk update as specified by the given expressionvoid
delete(long id)
This method deletes an entity.void
delete(long id, int code)
This method deletes an entity and you can give a deletion codevoid
deleteAll(Collection<T> entities)
Deletes all entries form the databasevoid
deleteAll(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.T
findById(long id)
This method finds an entity by IDT
findById(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.List<Object>
findByQuery(String query, Object[] values, Integer max)
Deprecated.List<Object>
findByQuery(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)
Deprecated.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.String
getDbms()
Get the DBMS name currently connected(possible values are: mysql, hsqldb, oracle, mssql)void
initialize(T entity)
Initialises lazy loaded data such as collectionsboolean
isOracle()
int
jdbcUpdate(String statement)
Executes the given SQL update statementint
jdbcUpdate(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 argumentsList
query(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.int
queryForInt(String sql)
Execute a query that results in an int value, given static SQL.List
queryForList(String sql, Class elementType)
Execute a query for a result list, given static SQL.List
queryForList(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.long
queryForLong(String sql)
Execute a query that results in an long value, given static SQL.long
queryForLong(String statement, Object... args)
Execute a query that results in an long value, given static SQL.Object
queryForObject(String sql, Class type)
Execute a query that results in a Object value, given static SQL.org.springframework.jdbc.support.rowset.SqlRowSet
queryForRowSet(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 RowSetString
queryForString(String sql)
Execute a query that results in an string value, given static SQL.void
store(T entity)
This method persists the entity object
-
-
-
Field Detail
-
ENTITY
static final String ENTITY
The alias to use to reference the object in the queries- See Also:
- Constant Field Values
-
-
Method Detail
-
store
void store(T entity) throws PersistenceException
This method persists the entity object- Parameters:
entity
- entity to be stored- Throws:
PersistenceException
- raised in case of errors in the database
-
findById
T findById(long id) throws PersistenceException
This 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
-
findById
T findById(long id, boolean initialize) throws PersistenceException
This method finds an entity by ID- Parameters:
id
- ID of the entityinitialize
- 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
-
findAll
List<T> findAll(long tenantId)
Finds all entities in a specific tenant.- Parameters:
tenantId
- Identifier of the tenant to search in- Returns:
- The list of all entities
-
findAllIds
List<Long> findAllIds(long tenantId)
Finds all entities ids in a specific tenant.- Parameters:
tenantId
- Identifier of the tenant to search in- Returns:
- The list of all entities ids
-
findByWhere
List<T> findByWhere(String where, String order, Integer max) throws PersistenceException
Finds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Parameters:
where
- The where clause expressionorder
- The order clause expressionmax
- Maximum results number (optional)- Returns:
- The list of marching entities
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByWhere
@Deprecated(since="8.9") List<T> findByWhere(String where, Object[] values, String order, Integer max) throws PersistenceException
Deprecated.Finds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Parameters:
where
- The where clause expressionvalues
- Parameters used in the where expressionorder
- The order clause expressionmax
- Maximum results number (optional)- Returns:
- The list of marching entities
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByWhere
List<T> findByWhere(String where, Map<String,Object> parameters, String order, Integer max) throws PersistenceException
Finds all entities by the given expression. Use "_entity" alias to reference attributes in the where expression.- Parameters:
where
- The where clause expressionparameters
- Parameters used in the where expressionorder
- The order clause expressionmax
- Maximum results number (optional)- Returns:
- The list of marching entities
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByObjectQuery
List<T> findByObjectQuery(String query, Object[] values, Integer max) throws PersistenceException
Finds all entities by the given object query.- Parameters:
query
- The query expression (for positional parameters, please use JPA-style: ?1, ?2 ...)values
- Parameters used in the where expressionmax
- Maximum results number (optional)- Returns:
- The list of matching entities
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByObjectQuery
List<T> findByObjectQuery(String query, Map<String,Object> parameters, Integer max) throws PersistenceException
Finds all entities by the given object query.- Parameters:
query
- The query expressionparameters
- Parameters used in the where expressionmax
- Maximum results number (optional)- Returns:
- The list of matching entities
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByQuery
@Deprecated(since="8.9") List<Object> findByQuery(String query, Object[] values, Integer max) throws PersistenceException
Deprecated.Find everything you want from the DB using the ORM query language- Parameters:
query
- The query to execute (for positional parameters, please use JPA-style: ?1, ?2 ...)values
- Array of paramatersmax
- Maximum results number (optional)- Returns:
- Query result
- Throws:
PersistenceException
- raised in case of errors in the database
-
findByQuery
List<Object> findByQuery(String query, Map<String,Object> parameters, Integer max) throws PersistenceException
Find everything you want from the DB using the ORM query language- Parameters:
query
- The query to executeparameters
- The map of the parametersmax
- Maximum results number (optional)- Returns:
- Query result
- Throws:
PersistenceException
- raised in case of errors in the database
-
findIdsByWhere
List<Long> findIdsByWhere(String where, String order, Integer max) throws PersistenceException
Finds all entities ids by the given expression. Use "_entity" alias to reference attributes in the where expression.- Parameters:
where
- The where clause expressionorder
- The order clause expressionmax
- Maximum results number (optional)- Returns:
- The list of marching entities ids
- Throws:
PersistenceException
- raised in case of errors in the database
-
findIdsByWhere
List<Long> findIdsByWhere(String where, Object[] values, String order, Integer max) throws PersistenceException
Finds all entities ids by the given expression. Use "_entity" alias to reference attributes in the where expression.- Parameters:
where
- The where clause expression (for positional parameters, please use JPA-style: ?1, ?2 ...)values
- Parameters used in the where expressionorder
- The order clause expressionmax
- Maximum results number (optional)- Returns:
- The list of marching entities ids
- Throws:
PersistenceException
- raised in case of errors in the database
-
initialize
void initialize(T entity)
Initialises lazy loaded data such as collections- Parameters:
entity
- The entity to be initialised
-
query
List query(String sql, Object[] args, org.springframework.jdbc.core.RowMapper 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 executeargs
- 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 scalemaxRows
- the new max rows limit; null means there is no limitrowMapper
- object that will map one object per row- Returns:
- the result List, containing mapped objects
- Throws:
PersistenceException
- raised in case of errors in the database
-
queryForRowSet
org.springframework.jdbc.support.rowset.SqlRowSet queryForRowSet(String sql, Object[] args, Integer maxRows) throws PersistenceException
Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, returns a navigable RowSet- Parameters:
sql
- SQL query to executeargs
- 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 scalemaxRows
- 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
-
queryForList
List queryForList(String sql, Object[] args, Class elementType, Integer maxRows) throws PersistenceException
Query 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 executeelementType
- the required type of element in the result list (for example, Integer.class)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 scalemaxRows
- 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
List queryForList(String sql, Class elementType) 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 executeelementType
- 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
-
queryForInt
int queryForInt(String sql) throws PersistenceException
Execute 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
-
queryForLong
long queryForLong(String sql) throws PersistenceException
Execute 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
-
queryForLong
long queryForLong(String statement, Object... args) throws PersistenceException
Execute 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:
statement
- SQL query to executeargs
- 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
-
queryForString
String queryForString(String sql) throws PersistenceException
Execute 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
-
queryForObject
Object queryForObject(String sql, Class type) throws PersistenceException
Execute 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 executetype
- The type of the returned value- Returns:
- the object value
- Throws:
PersistenceException
- raised in case of errors in the database
-
delete
void delete(long id) throws PersistenceException
This 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
-
delete
void delete(long id, int code) throws PersistenceException
This method deletes an entity and you can give a deletion code- Parameters:
id
- ID of the entity which should be deletedcode
- Deletion code- Throws:
PersistenceException
- raised in case of errors in the database
-
deleteAll
void deleteAll(Collection<T> entities) throws PersistenceException
Deletes all entries form the database- Parameters:
entities
- The entities to be deleted- Throws:
PersistenceException
- raised in case of errors in the database
-
deleteAll
void deleteAll(Collection<T> entities, int code) throws PersistenceException
Deletes all entries form the database giving a specific deletion code- Parameters:
entities
- The entities to be deletedcode
- The deletion code- Throws:
PersistenceException
- raised in case of errors in the database
-
bulkUpdate
@Deprecated(since="8.9") int bulkUpdate(String expression, Object[] values) throws PersistenceException
Deprecated.Executes a bulk update as specified by the given expression- 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
-
bulkUpdate
int bulkUpdate(String expression, Map<String,Object> parameters) throws PersistenceException
Executes a bulk update as specified by the given 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
-
jdbcUpdate
int jdbcUpdate(String statement) throws PersistenceException
Executes the given SQL update statement- 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
-
jdbcUpdate
int jdbcUpdate(String statement, Object... args) throws PersistenceException
Issue a single SQL update operation (such as an insert, update or delete statement) via a prepared statement, binding the given arguments- Parameters:
statement
- SQL containing bind parametersargs
- 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
-
getDbms
String getDbms()
Get the DBMS name currently connected(possible values are: mysql, hsqldb, oracle, mssql)- Returns:
- the database identifier
-
isOracle
boolean isOracle()
-
-