T
- The type of entity.ID
- The type of the entity's id.public abstract class DefaultGenericDaoDbFacade<T extends BusinessEntity<ID>,ID extends Serializable> extends BaseDAODbFacade implements GenericDao<T,ID>
GenericDao
which provides a default implementation for all the methods which only
requires extending classes to provide procedure names and relevant mapper classes.dbFacade, dialect, jdbcTemplate, RETURN_VALUE_PARAMETER
Constructor and Description |
---|
DefaultGenericDaoDbFacade() |
Modifier and Type | Method and Description |
---|---|
protected abstract org.springframework.jdbc.core.simple.ParameterizedRowMapper<T> |
createEntityRowMapper()
Create a row mapper to map results to the entity.
|
protected abstract org.springframework.jdbc.core.namedparam.MapSqlParameterSource |
createFullParametersMapper(T entity)
Create a parameter mapper to map all entity fields to procedure parameters.
|
protected abstract org.springframework.jdbc.core.namedparam.MapSqlParameterSource |
createIdParameterMapper(ID id)
Create a parameter mapper to map the entity id to the id in the procedure parameters.
|
protected org.springframework.jdbc.core.simple.SimpleJdbcCallOperations |
createQueryCall(String procedureName)
Create a
SimpleJdbcCallOperations used to call the given query procedure.Warning: This call should be used only for fetching entities. |
T |
get(ID id)
Retrieves the entity with the given id.
|
List<T> |
getAll()
Retrieves all the entities of type
T . |
protected abstract String |
getProcedureNameForGet() |
protected abstract String |
getProcedureNameForGetAll() |
protected abstract String |
getProcedureNameForRemove() |
protected abstract String |
getProcedureNameForSave() |
protected abstract String |
getProcedureNameForUpdate() |
protected void |
modify(String procedureName,
org.springframework.jdbc.core.namedparam.MapSqlParameterSource paramSource) |
void |
remove(ID id)
Removes the entity with the given id from the underlying store of data.
|
void |
save(T entity)
Persist a new instance of the entity.
|
protected void |
update(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations callToUpdate,
T entity) |
void |
update(T entity)
Update the entity in the DB using the given
SimpleJdbcCallOperations . |
getCallsHandler, getCustomMapSqlParameterSource, setDbFacade, setDialect, setTemplate
public void update(T entity)
SimpleJdbcCallOperations
.update
in interface ModificationDao<T extends BusinessEntity<ID>,ID extends Serializable>
entity
- The image dynamic data.protected abstract String getProcedureNameForUpdate()
protected void update(org.springframework.jdbc.core.simple.SimpleJdbcCallOperations callToUpdate, T entity)
public T get(ID id)
ReadDao
get
in interface ReadDao<T extends BusinessEntity<ID>,ID extends Serializable>
id
- The id to look by (can't be null
).null
if not found.protected abstract String getProcedureNameForGet()
public List<T> getAll()
ReadDao
T
.getAll
in interface ReadDao<T extends BusinessEntity<ID>,ID extends Serializable>
protected abstract String getProcedureNameForGetAll()
protected void modify(String procedureName, org.springframework.jdbc.core.namedparam.MapSqlParameterSource paramSource)
public void save(T entity)
ModificationDao
save
in interface ModificationDao<T extends BusinessEntity<ID>,ID extends Serializable>
entity
- The entity to persist (can't be null
).protected abstract String getProcedureNameForSave()
public void remove(ID id)
ModificationDao
remove
in interface ModificationDao<T extends BusinessEntity<ID>,ID extends Serializable>
id
- The id of the entity to remove (can't be null
).protected abstract String getProcedureNameForRemove()
protected abstract org.springframework.jdbc.core.namedparam.MapSqlParameterSource createIdParameterMapper(ID id)
id
- The entity to map id for.protected abstract org.springframework.jdbc.core.namedparam.MapSqlParameterSource createFullParametersMapper(T entity)
entity
- The entity to map parameters for.protected abstract org.springframework.jdbc.core.simple.ParameterizedRowMapper<T> createEntityRowMapper()
protected org.springframework.jdbc.core.simple.SimpleJdbcCallOperations createQueryCall(String procedureName)
SimpleJdbcCallOperations
used to call the given query procedure.procedureName
- The name of the stored procedure to call.SimpleJdbcCallOperations
which can be used to call the procedure.Copyright © 2012. All Rights Reserved.