@Repository public class JdbcGenericDao<T extends GenericEntity,Pk extends Serializable> extends Object implements GenericDao<T,Pk>, org.springframework.beans.factory.InitializingBean
| 构造器和说明 |
|---|
JdbcGenericDao(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate npJdbcTemplate) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
afterPropertiesSet() |
boolean |
batchSave(List<T> entityList,
Integer batchSize)
批量添加实体
|
boolean |
batchUpdate(List<T> entityList,
Integer batchSize)
批量更新实体
|
boolean |
batchUpdate(List<T> entityList,
String[] fields,
Integer batchSize)
批量更新实体
|
Long |
count(Class<T> clazz,
Conditions conditions,
Map<String,Object> params)
数量查询
|
Long |
countQuery(String sql,
Map<String,Object> param)
数量查询
|
boolean |
delete(Class<T> clazz,
Pk id)
根据主键删除实体
|
void |
execute(String sql)
执行SQL语句
|
int |
execute(String sql,
Map<String,Object> params)
执行带参数的SQL语句
|
T |
get(Class<T> clazz,
Pk id)
根据主键获取实体详细信息
|
List<T> |
list(Class<T> clazz,
String sql)
列表查询
|
List<T> |
list(Class<T> clazz,
String sql,
Map<String,Object> params)
列表查询
|
List<Map<String,Object>> |
list(String sql)
列表查询
|
List<Map<String,Object>> |
list(String sql,
Map<String,Object> params)
列表查询
|
T |
load(Class<T> clazz,
Pk id)
获取指定的实体信息
|
List<T> |
page(Class<T> clazz,
Page page)
分页查询
|
T |
queryForEntity(Class<T> clazz,
Condition condition,
Map<String,Object> params)
条件查询
|
List<T> |
queryForList(Class<T> clazz,
Conditions conditions,
Map<String,Object> paramMap)
条件查询
|
boolean |
remove(Class<T> clazz,
Pk id)
根据主键逻辑删除实体
|
void |
save(T entity)
保存实体
|
boolean |
update(T entity)
更新实体
|
boolean |
update(T entity,
String[] fields)
更新指定字段
|
@Autowired
public JdbcGenericDao(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate npJdbcTemplate)
public void save(T entity) throws DatabaseException
GenericDaosave 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entity - 实体对象DatabaseException - 运行异常public boolean batchSave(List<T> entityList, Integer batchSize) throws DatabaseException
GenericDaobatchSave 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entityList - 对象数组batchSize - 批量大小DatabaseException - 运行异常public boolean update(T entity) throws DatabaseException
GenericDaoupdate 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entity - 实体对象DatabaseException - 运行异常public boolean update(T entity, String[] fields) throws DatabaseException
GenericDaoupdate 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entity - 实体对象 必须要包含主键值fields - 需要更新的属性列DatabaseException - 运行异常public boolean batchUpdate(List<T> entityList, Integer batchSize) throws DatabaseException
GenericDaobatchUpdate 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entityList - 需要更新的实体类列表batchSize - 批量大小DatabaseException - 运行异常public boolean batchUpdate(List<T> entityList, String[] fields, Integer batchSize) throws DatabaseException
GenericDaobatchUpdate 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>entityList - 需要更新的实体类列表fields - 需要更新的实体属性batchSize - 批量大小DatabaseException - 运行异常public boolean delete(Class<T> clazz, Pk id) throws DatabaseException
GenericDaodelete 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类id - 主键DatabaseException - 运行异常public boolean remove(Class<T> clazz, Pk id) throws DatabaseException
GenericDaoremove 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类id - 主键DatabaseException - 运行异常public void execute(String sql) throws DatabaseException
GenericDaoexecute 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>sql - SQL语句 需要执行的参数DatabaseException - 运行异常public int execute(String sql, Map<String,Object> params)
GenericDaoexecute 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>sql - SQL语句 待执行的SQL语句params - 参数public T queryForEntity(Class<T> clazz, Condition condition, Map<String,Object> params) throws DatabaseException
GenericDaoqueryForEntity 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类condition - 查询条件params - 查询参数DatabaseException - 运行异常public T get(Class<T> clazz, Pk id) throws DatabaseException
GenericDaoget 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类id - 主键DatabaseException - 运行异常public T load(Class<T> clazz, Pk id) throws DatabaseException
GenericDaoload 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类id - 主键DatabaseException - 运行异常public List<Map<String,Object>> list(String sql) throws DatabaseException
GenericDaolist 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>sql - SQL语句DatabaseException - 运行异常public List<T> page(Class<T> clazz, Page page) throws DatabaseException
GenericDaopage 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 查询实体page - 分页查询DatabaseException - 运行异常public List<T> list(Class<T> clazz, String sql) throws DatabaseException
GenericDaolist 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 查询实体sql - 查询语句DatabaseException - 运行异常public List<Map<String,Object>> list(String sql, Map<String,Object> params) throws DatabaseException
GenericDaolist 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>sql - 查询语句params - 查询参数DatabaseException - 运行异常public List<T> list(Class<T> clazz, String sql, Map<String,Object> params) throws DatabaseException
GenericDaolist 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类sql - 查询语句params - 查询参数DatabaseException - 运行异常public Long countQuery(String sql, Map<String,Object> param) throws DatabaseException
GenericDaocountQuery 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>sql - SQL语句param - 查询条件DatabaseException - 运行异常public Long count(Class<T> clazz, Conditions conditions, Map<String,Object> params) throws DatabaseException
GenericDaocount 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类conditions - 查询条件params - 参数DatabaseException - 运行异常public List<T> queryForList(Class<T> clazz, Conditions conditions, Map<String,Object> paramMap) throws DatabaseException
GenericDaoqueryForList 在接口中 GenericDao<T extends GenericEntity,Pk extends Serializable>clazz - 实体类conditions - 查询条件paramMap - 查询参数DatabaseException - 运行异常public void afterPropertiesSet()
throws DatabaseException
afterPropertiesSet 在接口中 org.springframework.beans.factory.InitializingBeanDatabaseExceptionCopyright © 2019. All rights reserved.