SQL for NamedQuery in EclipseLink

核能气质少年 提交于 2019-12-12 01:34:47

问题


I want to write following query as NamedQuery in Eclipselink

   select o  from user o where trunc(o.TRSF_DATE) = ?1 and o.contrno in(?2,?3,?4,?5,?6,?7,?8,?9,?10,?11)

I am getting following error

   Internal Exception: NoViableAltException(83!=[661:1: simpleConditionalExpressionRemainder[Object left] returns [Object node] : (n= compariso
nExpression[left] | (n1= NOT )? n= conditionWithNotExpression[(n1!=null), left] | IS (n2= NOT )? n= isExpression[(n2!=null), left] );])
        at org.eclipse.persistence.exceptions.JPQLException.unexpectedToken(JPQLException.java:372)

Regards,


回答1:


My guess is that the error is caused by trunc, which is not a valid JPQL function. In EclipseLink you can use the FUNC keyword to call a database function.

See, http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Support_for_Native_Database_Functions



来源:https://stackoverflow.com/questions/8430555/sql-for-namedquery-in-eclipselink

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!