Criteria API and Regexp [message #1445317] |
Wed, 15 October 2014 05:16  |
Eclipse User |
|
|
|
Hello,
I am trying to use EclipseLink RegExp expression with the Criteria API.
The problem is I'm using a framework (Vaadin's JPAContainer) that forces me to use predicates and with JpaCriteriaBuilder I can only get an expression.
This code should help understand:
@Override
public void filtersWillBeAdded(CriteriaBuilder criteriaBuilder, CriteriaQuery<?> query, List<Predicate> predicates) {
JpaCriteriaBuilder cb = (JpaCriteriaBuilder) criteriaBuilder;
Root<?> r = query.getRoots().iterator().next();
Expression exp = cb.fromExpression(cb.toExpression(r.get("field")).regexp(REGEXP));
// how can I cast the previous expression to a predicate so that I can add it to the list of predicates??
}
Any help will be highly appreciated!! Thanks,
Francesco
|
|
|
|
|
Re: Criteria API and Regexp [message #1701320 is a reply to message #1448844] |
Sat, 11 July 2015 04:27  |
Eclipse User |
|
|
|
Hi Chris,
I am running into this exact problem while trying to use REGEXP function through CriteriaAPI.
In your below statement, what's ClassConstants.BOOLEAN?
Predicate predicate = cb.isTrue(new ExpressionImpl(model, ClassConstants.BOOLEAN, exp) );
|
|
|
Powered by
FUDForum. Page generated in 0.03077 seconds