I'm trying to crete Criteria API query with JSON_VALUE function() is Oracle12c:
select * from orderswhere (JSON_VALUE(duty, '$.department') in ( ? , ? , ? ,? , ? , ? , ?));
MODEL:
@Entity
@Table(name = "orders")
@EntityListeners(AuditingEntityListener.class)
public class Trade implements Serializable {
@Convert(converter = JpaConverterJson.class)
private Map<String, Object> duty;
.....
}
private Specification<InvoicePurchase> reportFormToSpec(Map<String, Object>
params) {
return (root, query, cb) -> {
List<Predicate> predicates = new ArrayList<>();
if (!StringUtils.isEmpty(params.get("department"))) {
Predicate predicate = cb.like(cb.function("json_value", String.class,
root.get("duty"),
cb.literal("$.department"))
, params.get("department"));
predicates.add(predicate);
}
return query.where(predicates.toArray(new Predicate[predicates.size()])).getRestriction();
};
}
But getting exception: o.h.engine.jdbc.spi.SqlExceptionHelper: ORA-40454:path expression not a literal
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.
ERROC CODE:
2017-11-23 12:26:55.271 WARN 11972 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 40454, SQLState: 99999
2017-11-23 12:26:55.271 ERROR 11972 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ORA-40454: path expression not a literal