【发布时间】:2012-03-26 22:05:32
【问题描述】:
我有一个这样的 sql 查询
select column from table where path = left('INPUTSTRING', length(path));
并尝试像这样在 hql 中完成它,
return session.createQuery("from Table where Path = left(:input, length(Path))").
query.setParameter("input", inputPath).
.list();
得到这样的错误
Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: left near line 1
如何做到这一点? hql中对应的字符串函数是什么?有没有使用条件查询 API 的解决方案?
【问题讨论】:
-
我不确定hbl是否支持left函数,尝试使用NamedNativeQueries。
标签: mysql sql hibernate hql criteria-api