Exemplo n.º 1
0
  private String addWhere(NotePage notePage, String hql, List<Object> values) {
    // 循环查询条件Page的所有[Integer][String]类型的字段,如果字段不为空则动态加上查询条件
    // -----------------------------------------------------
    StringBuffer hqlbf = new StringBuffer(hql);

    NoteEntity noteEntity = new NoteEntity();
    BeanUtils.copyProperties(notePage, noteEntity);
    SearchSqlGenerateUtil.createSearchParamsHql(hqlbf, values, noteEntity);
    hql = hqlbf.toString();
    // -----------------------------------------------------
    if (notePage.getCcreatedatetimeStart() != null) {
      hql += " and createDt>=? ";
      values.add(notePage.getCcreatedatetimeStart());
    }
    if (notePage.getCcreatedatetimeEnd() != null) {
      hql += " and createDt<=? ";
      values.add(notePage.getCcreatedatetimeEnd());
    }
    if (notePage.getCmodifydatetimeStart() != null) {
      hql += " and modifyDt>=? ";
      values.add(notePage.getCmodifydatetimeStart());
    }
    if (notePage.getCmodifydatetimeEnd() != null) {
      hql += " and modifyDt<=? ";
      values.add(notePage.getCmodifydatetimeEnd());
    }
    return hql;
  }