• mybatis_crud


    @Resource
        public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
            super.setSqlSessionFactory(sqlSessionFactory);
        }
    //全部数据集
    public List<T> selectAll() throws DataAccessException {
            List<T> result = new ArrayList<T>();
            try {
                result = this.getSqlSession().selectList(
                        getMapperNamespace() + "." + "selectAll");
            } catch (DataAccessException e) {
                throw e;
            }
            return result;
        }
    
    public Integer getTotalCount(Object params) throws DataAccessException {
            return getSqlSession().selectOne(
                    getMapperNamespace() + "." + "getTotalCount", params);
        }
    //插入一条数据
    @Override
        public boolean insertSelective(T entity) throws DataAccessException {
            return insert("insertSelective", entity);
        }
    //根据主键查询
    @Override
        public T selectByPrimaryKey(Integer pk) throws DataAccessException {
            T result = null;
            try {
                result = (T) this.getSqlSession().selectOne(
                        getMapperNamespace() + "." + "selectByPrimaryKey", pk);
            } catch (DataAccessException e) {
                throw e;
            }
            return result;
        }
    //根据参数查询
    @Override
        public boolean updateByMap(String id, Map<String, Object> map)
                throws DataAccessException {
            boolean flag = this.getSqlSession().update(getMapperNamespace() + "." + id,
                    map) > 0 ? true : false;
            return flag;
        }
    工作小总结,有错请指出,谢谢。
  • 相关阅读:
    装箱、拆箱操作发生在
    @Data的注解使用以及在IDEA上安装
    Mysql中 BLOB字段转String的方法
    不属于java语言鲁棒性特点的是
    java object默认的基本方法
    哪个类可用于处理 Unicode?
    类和接口的继承
    抽象类的叙述:
    Hashtable 和 HashMap 的区别是:
    编程之美初赛第一场--焦距
  • 原文地址:https://www.cnblogs.com/zilanghuo/p/5210815.html
Copyright © 2020-2023  润新知