Beispiel #1
0
 public CriteriaQuery(Class entityClass, DataTables dataTables) {
   this.curPage = dataTables.getDisplayStart();
   String[] fieldstring = dataTables.getsColumns().split(",");
   this.detachedCriteria =
       DetachedCriteriaUtil.createDetachedCriteria(entityClass, "start", "_table", fieldstring);
   // this.detachedCriteria = DetachedCriteria.forClass(c);
   this.field = dataTables.getsColumns();
   this.entityClass = entityClass;
   this.dataTables = dataTables;
   this.pageSize = dataTables.getDisplayLength();
   this.map = new HashMap<String, Object>();
   this.ordermap = new HashMap<String, Object>();
   addJqCriteria(dataTables);
 }
Beispiel #2
0
 /**
  * 加载dataTables 默认查询条件
  *
  * @param dataTables
  */
 public void addJqCriteria(DataTables dataTables) {
   String search = dataTables.getSearch(); // 查询关键字
   SortInfo[] sortInfo = dataTables.getSortColumns(); // 排序字段
   String[] sColumns = dataTables.getsColumns().split(","); // 字段
   if (StringUtil.isNotEmpty(search)) {
     for (String string : sColumns) {
       if (string.indexOf("_") == -1) {
         jqcriterionList.addPara(Restrictions.like(string, "%" + search + "%"));
       }
     }
     add(getOrCriterion(jqcriterionList));
   }
   if (sortInfo.length > 0) {
     for (SortInfo sortInfo2 : sortInfo) {
       addOrder("" + sColumns[sortInfo2.getColumnId()] + "", sortInfo2.getSortOrder());
     }
   }
 }