Mix JPQL and CriteriaQuery

Is it possible to mix JPQL and CriteriaQuery?

I have Stringone that contains the where clause in JPQL and CriteriaQuerywhich is already built and delivered from another place. I wonder if I can add a condition Stringto CriteriaQuery.where(). The where clause can be several "and-ed" / "or-ed" clauses together.

Can I do this indiscriminately on the condition String<? >

+3
source share
3 answers

Well, one thing you can do is convert CriteriaQuery to JPQL and concatenate the two parts of WHERE in the rows.

See the “JPQL equivalent query criteria” at http://www.datanucleus.org/products/accessplatform/jpa/jpql_criteria.html

+1

, JPA ( ). . TopLink ( EclipseLink) Expression.postfixSQL prefixSQL - , . Hibernate Restrictions.sqlRestriction.

.

+2

If there is a way to do this in JPA 1.0 or 2.0, I don't know about it, but this answer in another question suggests that mixing JPQL and CriteriaQuery will be available in JPA 2.1 (in the future).

+1
source

Source: https://habr.com/ru/post/1793969/


All Articles