3

I am using javax.persistence.criteria.CriteriaBuilder and I am having trouble using the persistence API to do this simple (oracle) SQL: SELECT * FROM foo ORDER BY json_value(json_text, '$.type');

What I have is

CriteriaBuilder cb= em.getCriteriaBuilder();
CriteriaQuery<Foo> query= cb.createQuery(Foo.class);
Root<QcJob> r = query.from(Foo.class);

Expression exp = cb.function("json_value", String.class, r.get("json_text"), cb.literal("$.type"));
query.orderBy(exp);

I get the following error ORA-40454: path expression not a literal because the underlying hibernate implementation generates this SQL: SELECT * FROM foo foo0_ order by json_value(foo0_.json_text, ?)

Oracle requires there to be a literal and no expression replacement. I found this https://stackoverflow.com/a/48721133/1738539, but I do not have org.hibernate.jpa.criteria.expression.LiteralExpression as I want to keep this agnostic to any specific implementation.

Is there anyway other way I can supply hibernate the inline literal for this function?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.