I\'m using spring-data-jpa and querydsl (3.2.3)
I have a scenario where I\'m creating set of predicates based on user filer/input. All of these comes to BooleanEx
Try this:
QInvoice invoice = QInvoice.invoice;
QCompany company = QCompany.company;
List<Invoice> list = new HibernateQuery(sessionFactory.getCurrentSession())
.from(invoice).where(
new HibernateSubQuery().from(invoice, company).where(
invoice.supplier.number.eq(company.number).and(
company.active.eq(true))).exists()).list(invoice);
Here is a variant of jaiwo99's answer in a more JPAesque form
BooleanExpression exp = invoice.supplier.number.in(new JPASubQuery()
.from(company)
.where(company.active.isTrue())
.list(company.number));
Feel free to merge this into the original answer.