### Question:
Query { public Criteria<E> createCriteria(Class<?> entityClass, SearchModel search) { Criteria<E> criteria = Criteria.createCriteria(entityClass, transformer); if(search == null) { return criteria; } if(search.getQ() != null && search.getQ().length() > 0) { String[] queries = new String[]{search.getQ()}; QueryUtility.configureCriteriaByQ(criteria, queries); } if(search.getFilter() != null && search.getFilter().length > 0) { QueryUtility.configureFilters(criteria, search.getFilter(), 0); } if(search.getSort() != null && search.getSort().length > 0) { QueryUtility.configureSorts(criteria, search.getSort()); } QueryUtility.configureSelectFields(criteria, search); if(search.getLimit() != null) { criteria.setLimit(search.getLimit()); } if(search.getOffset() != null) { criteria.setOffset(search.getOffset()); } return criteria; } Query(Transformer<E> transformer); Criteria<E> createCriteria(Class<?> entityClass, SearchModel search); static void addRestrictions(Criteria<E> criteria, String[][] filters); static void addProjections(Criteria<E> criteria, String[] projections); static void addOrder(Criteria<E> criteria, String[] sorts); static String checkStringAndTrim(String name); static Holder<E> configureFieldByName(Criteria<E> criteria, String name); static Object getValue(String operator, String rawValue, Class<?> fieldType); static Object getValue(Operator operator, String rawValue, Class<?> fieldType);  }### Answer:
@Test public void createCriteria() throws Exception { Session session = sessionFactory.openSession(); SearchModel search = new SearchModel(); search.setQ("Example First Role"); search.setFields(new String[]{"name", "nickNames"}); search.setSort(new String[]{"-name", "+roleOid.name"}); search.setFilter(new String[][] {{"name", "=", "Kamil"}, {"active", "=", "true"}}); Query<Map<String, Object>> query = new Query<>(new TransformerImpl<>(session, Criteria.MAP_CLASS)); Result<Map<String, Object>> result = query.createCriteria(User.class, search).add( Restrictions.in("name", "deneme, deneme") ).pairList(); System.out.println(result); }
@Test public void createCriteria2() throws Exception { Session session = sessionFactory.openSession(); SearchModel search = new SearchModel(); Query<Map<String, Object>> query = new Query<>(new TransformerImpl<>(session, Criteria.MAP_CLASS)); Result<Map<String, Object>> result = query.createCriteria(User.class, search) .setProjection(Projections .projectionList() .add(Projections.alias(Projections.groupProperty("active"), "active")) .add(Projections.alias(Projections.count("active"), "count")) .add(Projections.alias(Projections.avg("failCount"), "failCount")) ) .pairList(); System.out.println(result); }