访问数据库表公共接口方法

public interface CommonDao<T> {


    /**
     * 根据主键查询对象
     * 
     * @return
     */
    public T findById(long id);
    
    /**
     * 查询出所有的T对象
     * 
     * @return List<T>
     */
    public List<T> findAll();


    /**
     * 根据主键删除对象
     * 
     * @return
     */
    public void delete(long id);


    /**
     * 保存单一对象
     * 
     * @return T
     */
    public T save(T t);
    
    /**
     * 更新单一对象
     * 
     * @return T
     */
    public T update(T t);
    
    /**
     * 统计表个数
     * 
     * @return T
     */
    public Long count();
    
    /**
     * 按条件统计表个数
     * 
     * @return T
     */
    public Long countByFilter(String Filter);
    
    /**
     * jpa批量保存对象
     * 
     * @return
     */
    public void batchSave(List<T> tList);
    
    /**
     * jdbc批量保存对象 
     * 
     * @param valueSql 例:(1,2),(3,4)...
     */
    public void jdbcBatchSave(String valueSql);
    
    /**
     * 批量更新对象
     * 
     * @return
     */
    public void batchUpdate(List<T> tList);
    
    /**
     * 特定条件批量更新特定字段
     * 
     * @param filterSql 过滤条件(例 a = 1 and b=2...)
     * @param updateSql 更新语句(例 a = 1 and b = 2...)
     */
    public void jdbcBatchUpdate(String filterSql,String updateSql);
    
    
    /**
     * 特定条件查询数据集
     * 
     * @return List<T>
     */
    public List<T> findByFilter(String filterSql);
    
    /**
     * 多表查询返回数据集
     * 
     * @return List<T>
     */
    public List<T> findObjectBySql(String sql);
    
    
    /**
     * 按sql统计返回结果
     * 
     * @return List<T>
     */
    public Long countBySql(String sql);
    
    
    /**
     * 特定条件删除
     * 
     * @return List<T>
     */
    public void deleteByFilter(String filterSql);
    
    /**
     * 获取T对象Class
     * @return
     */
    public Class<T> getEntityClass();
    /**
     * 获取T对象所在表全名
     * @return
     */
    public String getEntityTable();
    
    /**
     * 条件查询返回特定字段集合
     * @return
     */
    public List<Map<String,Object>> findFieldsByFilter(List<String> fieldList,String filterSql);


    /**
     * 根据条件查询指定一个字段结果集
     * @param field
     * @param filterSql
     * @return
     */
    public List<Long> findFieldByFilter(String field,String filterSql);


    /**
     * 根据sql更新字段
     * @
     * @param updateSql
     * @return 
     */
    public int update(String updateSql);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值