Hello,
I use Querydsl in my application to greatly improve code for querying database.
However, I have a JPA Predicate (javax.persistence.criteria.Predicate) that comes from an external service.
I want to mix my query created with Querydsl and the external predicate. For example:
// JPA Predicate from external service
Root<User> root = ...;
CriteriaBuilder cb = ...;
javax.persistence.criteria.Predicate externalPredicate = externalService.filterEmail(root, cb, "%@gmail.com");
// Create Querydsl predicate
BooleanExpression querydslExp = QUser.username.eq("foo");
// Mix predicates (this is what I need)
querydslExp.and(externalPredicate);
Another solution could be converting Querydsl predicate into a JPA one:
cb.and(querydslExp.toJpaPredicate(), externalPredicate);
Is it possible ?
If yes, how can I achieve this ?
If no, is there another solution to mix predicates (like converting both to SQL strings and create a new query) ?
Thanks