I'm migrating some code that uses DetachedCriteria
of Hibernate to a new one using standard CriteriaBuilder
of JPA 2.1.
I have the following code :
criteria.add(Restrictions.sqlRestriction("sin(?) * sin(x) + cos(?) * cos(y) * cos(x- ?) <= ?", value, types))
;
I want to migrate it using CriteriaBuilder
but i didn't find a method in the JPA 2.1 Criteria API to use custom JPQL.
Is there any way to do it ?
PS: I'm using Specification
of Spring data JPA. So in my code I have access to CriteriaQuery
and CriteriaBuilder
.
public Predicate toPredicate(Root<Address> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
....
}