[英]How to fix “The Encapsulated Expression is Missing” error in JPA/Hibernate while using Update Named Query?
I am getting excapsulated expression missing issue while writing named query. 编写命名查询时,我遇到了缺少表达式的封装表达式。
int a = em.createQuery("UPDATE MyProsess d SET d.updateDate = current_date() WHERE d.personId = :personId")
Even when i pass multiple parameters to above query it gives some new errors. 即使当我将多个参数传递给上述查询时,它也会出现一些新错误。 For example
例如
int a = em.createQuery("UPDATE MyProsess d SET d.updateDate = current_date(), d.status=:stat WHERE d.personId = :personId")
Anyone could suggest how to resolve this issue? 任何人都可以建议如何解决此问题?
Ok I got it. 好,我知道了。 Please replace current_date() with "current_date" remove the brackets I think HQL is not able to recognize it with brackets.
请用“ current_date”替换current_date()删除方括号,我认为HQL无法使用方括号识别它。 Now in your Entities you have java.util.Date while current_date will return java.sql.Date this needs to be converted.
现在在您的实体中有java.util.Date,而current_date将返回java.sql.Date,这需要转换。 Mark the attribute updateDate with @Temporal(TemporalType.Date) annotation to ensure smooth conversion.
使用@Temporal(TemporalType.Date)批注标记属性updateDate以确保平滑转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.