AbstractQueryTranslator implements QueryTranslator<Q,O,P> { @SuppressWarnings("unchecked") protected <T> Q[] subqueries(Junction j, Class<T> entityClass) { List<Criterion> criteria = j.getCriteria(); List<Q> translated = new ArrayList<Q>(criteria.size()); for (Criterion c : criteria) { Q q = translate(c, entityClass); if (q != null) { translated.add(q); } } return translated.toArray((Q[]) Array.newInstance(queryClass, translated.size())); } AbstractQueryTranslator(Class<Q> queryClass,
            Class<O> orderClass,
            PropertyResolver propertyResolver); @Override Q translate(Query<T,R> query); @Override O translateOrder(Query<T, R> query); abstract Q eq(String fieldName, Object value); abstract Q ne(String fieldName, Object value); abstract Q lt(String fieldName, Object value); abstract Q lte(String fieldName, Object value); abstract Q gt(String fieldName, Object value); abstract Q gte(String fieldName, Object value); abstract Q between(String fieldName, Object from, Object to); abstract Q in(String fieldName, Object[] values); abstract Q notIn(String fieldName, Object[] values); abstract Q contains(String fieldName, Object[] values); abstract Q isNull(String fieldName); abstract Q notNull(String fieldName); abstract Q isEmpty(String fieldName); abstract Q notEmpty(String fieldName); abstract Q within(
            String fieldName, Point<N> center, Number distance); abstract Q and(Q... subqueries); abstract Q or(Q... subqueries); abstract O order(String fieldName, Order o); abstract O order(O... orders);  }
@Test public void subqueries() { Junction j = new Conjunction( Restrictions.eq(property, testValue), Restrictions.between(property, testFrom, testTo), Restrictions.in(property, testValues), Restrictions.isNotNull(property) ); String[] subqueries = translator.subqueries(j, entityClass); List<Criterion> criteria = j.getCriteria(); assertEquals(criteria.size(), subqueries.length); for (int i = 0; i < subqueries.length; i++) { assertEquals(translator.translate(criteria.get(i), entityClass), subqueries[i]); } }