- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
final QOrder qSub = new QOrder("qSub");
final Predicate[] filters = getFilters(qSub, null, null);
if (filters.length > 0) {
// conditions.add(Arrays.asList(filters)); // Do not do this.
// The subquery is here so that MySQL doesn't use the wrong index for
// ORDER BY... LIMIT if we directly add the filter by custid/custdept
// to the list of filters, which will make the search very slow.
// Well, perhaps an ugly workaround, and we might want to adjust
// the custid/custdept index in the future... somehow.
conditions.add(q.id.in(QueryDsl.subFrom(qSub).where(filters).list(qSub.id)));
}
Обход косяков конкретной СУБД на уровне ORM. Абстракция, что и говорить.