【发布时间】:2017-02-15 02:29:45
【问题描述】:
我正在尝试使用 JSON_VALUE 函数()的克里特标准 API 查询是 Oracle12c:
select * from orderswhere (JSON_VALUE(duty, '$.department') in ( ? , ? , ? ,? , ? , ? , ?));
型号:
@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();
};
}
但出现异常:o.h.engine.jdbc.spi.SqlExceptionHelper: ORA-40454:path expression not a literal
我在网上搜索了很长时间。但是没有用。请帮助或尝试提供一些想法如何实现这一目标。
错误代码:
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
【问题讨论】:
-
错误消息:2017-02-15 14:22:13.210 WARN 23176 --- [nio-8080-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper:SQL 错误:40454,SQLState :99999 2017-02-15 14:22:13.210 错误 23176 --- [nio-8080-exec-7] o.h.engine.jdbc.spi.SqlExceptionHelper:ORA-40454:路径表达式不是文字
标签: spring hibernate jpa spring-boot spring-data-jpa