java - @NamedQuery : FROM 子句中未定义标识变量“sysdate”
问题描述
我试图寻找它,但无法解决。需要你的想法
我正在使用这个 NamedQuery 从 Db 获取结果。
@NamedQuery(name= "Person.FindByCodeAndFiscalYear",
query="select o from Person o where o.fiscalYear=:pfiscalYear and o.Code=:pCode and (o.desactivatedDate is null or o.desactivatedDate > sysdate)")
在这里,我希望列 deactivateDate 为 null 或 sysdate
编译代码时出错:
Caused By: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Problem compiling [select o from Person o where o.fiscalYear=:pfiscalYear and o.Code=:pCode and (o.desactivatedDate is null or o.desactivatedDate > sysdate)].
[144, 151] The identification variable 'sysdate' cannot be used in conjunction with the > operator.
[144, 151] The identification variable 'sysdate' is not defined in the FROM clause.
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:155)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:347)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:278)
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:163)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142)
at org.eclipse.persistence.internal.jpa.JPAQuery.processJPQLQuery(JPAQuery.java:221)
at org.eclipse.persistence.internal.jpa.JPAQuery.prepare(JPAQuery.java:182)
at org.eclipse.persiste
解决方案
SYSDATA 是 Oracle 特定的,而 CURRENT_DATA 是 SQL 和 JPQL 标准。
推荐阅读
- javascript - php中未解析的变量
- javascript - 如何更改 onItemAdd 事件中的项目值?- 选择.js
- python-3.x - Pytest.paramterize 需要在另一个 pytest 测试生成的列表上运行
- hash - 如何从整数向量生成唯一的哈希键?
- json - 合并和排序 JSON 数组
- python - None 背后的概念是什么?
- java - 我得到了 listView 中每个项目的密钥并将其保存到 Firebase 我想将该密钥发送到另一个活动,但每次我得到相同的密钥
- python - 如何更改在pyqt5 python3中单击按钮时显示的.ui文件
- service-worker - 使用 Service Worker 管理服务器端事件
- python - 无法检索烧瓶中的值