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?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…