@SuppressWarnings("unchecked")
  @Override
  public <R> List<R> executeQuery(
      String sqlNamespace, String queryName, Object parameterObj, int offset, int limit) {
    if (offset < 0 || offset == Integer.MAX_VALUE) {
      throw new IllegalArgumentException("Query result offset must be zero or greater.");
    }

    if (limit <= 0) {
      throw new IllegalArgumentException("Query results limit must be greater than zero.");
    }

    String query = makeQueryName(sqlNamespace, queryName);
    try {
      List<R> result;
      if ((offset == 0) && (limit == Integer.MAX_VALUE)) {
        result = (List<R>) template.selectList(query, parameterObj);
      } else {
        RowBounds bounds = new RowBounds(offset, limit);
        result = (List<R>) template.selectList(query, parameterObj, bounds);
      }

      // Done
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Executed query: \n"
                + "   Query:  "
                + query
                + "\n"
                + "   Params: "
                + parameterObj
                + "\n"
                + "   Result: "
                + result);
      }
      return result;
    } catch (ClassCastException e) {
      throw new IllegalArgumentException("Return type of query does not match expected type.", e);
    } catch (Throwable e) {
      throw new QueryException(
          "Failed to execute query: \n"
              + "   Namespace: "
              + sqlNamespace
              + "\n"
              + "   queryName: "
              + queryName
              + "\n"
              + "   Parameter: "
              + parameterObj
              + "\n"
              + "   Offset:    "
              + offset
              + "\n"
              + "   Limit:     "
              + limit,
          e);
    }
  }
Пример #2
0
 public List<SysApplication> getSysApplicationsByQueryCriteria(
     int start, int pageSize, SysApplicationQuery query) {
   RowBounds rowBounds = new RowBounds(start, pageSize);
   List<SysApplication> rows =
       sqlSessionTemplate.selectList("getSysApplications", query, rowBounds);
   return rows;
 }
Пример #3
0
  public List<BoardDTO> dbSelect(int start, int end, String skey, String sval) {
    logger.info("\nBoardDAO class List<BoardDTO> dbSelect()");

    dto.setStart(start);
    dto.setEnd(end);
    dto.setSkey(skey);
    dto.setSval(sval);
    return sqlSession.selectList("selectAll", dto);
  } // end dbSelect
Пример #4
0
  /** @함수이름 : myPageHistoryListSelect @작성일 : 2015. 12. 11. @개발자 : 오주석 @설명 : */
  @Override
  public List<UserOrderDto> myPageHistoryListSelect(int startRow, int endRow, String member_id) {

    HashMap<String, Object> hMap = new HashMap<String, Object>();
    hMap.put("startRow", startRow);
    hMap.put("endRow", endRow);
    hMap.put("member_id", member_id);

    return sqlSessionTemplate.selectList("dao.myPageMapper.myPageHistoryListSelect", hMap);
  }
Пример #5
0
  /**
   * 根据查询条件得到集合,支持自定义范围
   *
   * @param statementName 查询使用的sql_id,不包含包名
   * @param condition 查询的条件
   * @param offset 记录起始位置,第一条记录
   * @param limit 结果集大小
   * @return 查询到的结果集List
   */
  @SuppressWarnings("rawtypes")
  public List findList(String statementName, Object condition, int offset, int limit) {
    RowBounds rb = new RowBounds(offset, limit);
    List list = null;

    list =
        sqlSessionTemplate.selectList(
            getMbatisMapperNamesapce() + "." + statementName, condition, rb);

    return list;
  }
Пример #6
0
 public List<Image> getImageList(Integer pagenum, Integer pagesize) {
   PageQuery pageQuery = new PageQuery((pagenum - 1) * pagesize, pagesize);
   return sqlSessionTemplate.selectList("getImageList", pageQuery);
 }
Пример #7
0
 public List<BoardDTO> dbSelect() {
   logger.info("\nBoardDAO class List<BoardDTO> dbSelect()");
   List<BoardDTO> list = sqlSession.selectList("selectAll");
   return list;
 } // end dbSelect
Пример #8
0
 /**
  * @name : coupon_data_list
  * @date : 2015. 7. 15.
  * @author : 황준
  * @description :쿠폰 리스트 조회
  */
 @Override
 public List<HashMap<String, Object>> coupon_data_list(int board_no) {
   // TODO Auto-generated method stub
   return sqlSession.selectList("dao.BoardMapper.coupon_data_list", board_no);
 }
 @Override
 public List<MemberDto> getMemberList(int groupNum) {
   // TODO Auto-generated method stub
   return sqlSession.selectList("member.dao.mapper.getMemberList", groupNum);
 }
Пример #10
0
 public List<AppClientDto> getDisabledAll(int page) {
   return sqlSession.selectList("appclient.getDisabledAllPage", page);
 }
Пример #11
0
 @Override
 public List<App> selectAll() {
   return sqlSession.selectList("selectAppAll");
 }
 @Override
 public List<T> findAll() {
   Map<String, ID> params = new HashMap<>();
   return sessionTemplate.selectList(mappedStatementId, params);
 }
Пример #13
0
 @Override
 public List<Code> getSelectCodeList(Code code) throws DataAccessException {
   return sqlSessionTemplate.selectList("Common.selectCodeList", code);
 }
Пример #14
0
 public List<StoreDTO> dbStoreSelectAll() {
   List<StoreDTO> list = sql.selectList("store.select");
   return list;
 }
Пример #15
0
 public List<BoardDTO> getReplyList(int hobby_no) {
   logger.info("BoardDAO class List<BoardDTO> getReplyList(int idx)");
   return sqlSession.selectList("getReplyList", hobby_no);
 }
Пример #16
0
 @SuppressWarnings("rawtypes")
 public List selectList(String queryId, Object params) {
   printQueryId(queryId);
   return sqlSession.selectList(queryId, params);
 }
Пример #17
0
 public List<AppClientDto> getDisabledAll() {
   return sqlSession.selectList("appclient.getDisabledAll");
 }
Пример #18
0
 @Override
 public List<App> selectByUsername(String username) {
   return sqlSession.selectList("selectAppByUsername", username);
 }
Пример #19
0
 @Override
 public List<ServicePara> get(Integer appId) {
   return (List<ServicePara>) sqlSession.selectList("getServiceByAppId", appId);
 }
 /**
  * 分页查询 <br>
  * ps:如果要实现物理分页,需要添加分页插件
  *
  * @param statement SQL语句的Id号(命名空间+name)
  * @param parameter 参数
  * @param pageNumber 当前页
  * @param pageSize 每页大小
  */
 public <T> List<T> paginate(String statement, Object parameter, int pageNumber, int pageSize) {
   int offset = (pageNumber - 1) * pageSize;
   List<T> retList = sqlSession.selectList(statement, parameter, new RowBounds(offset, pageSize));
   return retList;
 }
Пример #21
0
 /**
  * @name : getHeaderCondition
  * @date : 2015. 7. 02.
  * @author : 황준
  * @description : 블로그 작성시 불러올 카테고리 목록
  */
 @Override
 public List<String> getHeaderCondition() {
   logger.info("BoardDao getHeaderCondition DAO-------------------------");
   List<String> headerList = sqlSession.selectList("dao.BoardMapper.getHeaderCondition");
   return headerList;
 }
 /**
  * 查询记录集合<br>
  * ps:类型T可以是一个JavaBean也可以是一个Map
  *
  * @param statement SQL语句的Id号(命名空间+name)
  * @param parameter 查询条件对象(Map or JavaBean)
  */
 public <T> List<T> queryForList(String statement, Object parameter) {
   return sqlSession.selectList(statement, parameter);
 }
 public List<Dept> findAll() {
   List<Dept> list = template.selectList("findAll");
   return list;
 }
 /**
  * 查询记录集合<br>
  * ps:类型T可以是一个JavaBean也可以是一个Map
  *
  * @param statement SQL语句的Id号(命名空间+name)
  */
 public <T> List<T> queryForList(String statement) {
   return sqlSession.selectList(statement);
 }
Пример #25
0
 public List<Children> selectAll() {
   List<Children> list = sqlSession.selectList("children.selectAll");
   return list;
 }
  public void writeLog(CoreModel model, String operateType) {
    String name = model.getClass().getName();
    Map<String, Object> param = new HashMap<String, Object>();
    param.put("className", name);
    param.put("outLog", "Y");
    List<Table> tableList =
        sqlSessionTemplate.selectList(
            "com.delmar.core.mybatis.sql.TableMapper.selectByExample", param);

    Table table = null;
    if (tableList != null && tableList.size() > 0) {
      table = tableList.get(0);
    }
    try {
      if (table != null) {
        param = new HashMap<String, Object>();
        param.put("tableId", table.getId());
        List<TableColumn> tableColumnList =
            sqlSessionTemplate.selectList(
                "com.delmar.core.mybatis.sql.TableColumnMapper.selectByExample", param);
        Map<String, Object> obj = new HashMap<String, Object>();
        if (tableColumnList != null) {
          for (TableColumn column : tableColumnList) {
            obj.put(
                column.getAttributeName(),
                PropertyUtils.getProperty(model, column.getAttributeName()));
          }
        }
        Changelog log = new Changelog();
        log.setOperateType(operateType);
        log.setCreated(new Date());
        log.setContext(gson.toJson(obj));

        if (request != null) {
          UserInterface user = (UserInterface) request.getSession().getAttribute("loginUser");
          if (user != null) {
            log.setUserId(user.getId());
            log.setUsername(user.getUsername());
          } else {
            String userName = SessionContent.getUserId(Thread.currentThread().getId());
            log.setUsername(userName);
          }
        } else {
          String userName = SessionContent.getUserId(Thread.currentThread().getId());
          log.setUsername(userName);
        }

        Object pk = PropertyUtils.getProperty(model, "id");
        if (pk != null) log.setPk((Integer) pk);
        if (StringUtil.isNotEmpty(table.getBuPk())) {
          Object buPk = PropertyUtils.getProperty(model, table.getBuPk());
          if (buPk != null) log.setBuPk(buPk.toString());
        }

        log.setTableId(table.getId());
        sqlSessionTemplate.insert("com.delmar.core.mybatis.sql.ChangelogMapper.insert", log);
      }

    } catch (Exception e) {
      logger.error("插入操作日志异常", e);
    }
  }
Пример #27
0
  /** @함수이름 : myPageCouponSelect @작성일 : 2015. 12. 11. @개발자 : 오주석 @설명 : */
  @Override
  public List<UserCouponDto> myPageCouponSelect(String member_id) {

    return sqlSessionTemplate.selectList("dao.myPageMapper.myPageCouponSelect", member_id);
  }
Пример #28
0
 public List<MonthVO> month5() {
   return template.selectList("main.month5");
 }