在 JPQL 中,如何访问命名参数的属性?
我正在使用 Hibernate 3.5.4-Final。
我想将一个实体作为命名查询的参数传递,然后访问该查询中该命名参数的持久属性。我想这样做:
@NamedQuery(name = "hello", query = "SELECT p FROM WorkPackage p WHERE p IN (:workPackage).relatedWorkflows")
问题是在查询接近结束时,
(:workPackage).relatedWorkflows
导致 Hibernate 抛出部署时 QuerySyntaxException。删除括号没有帮助;为了清楚起见,我把它们留在了里面。有什么办法可以解决这个问题,还是我必须以编程方式执行此操作?
I'm using Hibernate 3.5.4-Final.
I want to pass an entity as a parameter of a named query, and then access a persisted property of that named parameter in that query. I want to do this:
@NamedQuery(name = "hello", query = "SELECT p FROM WorkPackage p WHERE p IN (:workPackage).relatedWorkflows")
The problem is near the end of the query, in the
(:workPackage).relatedWorkflows
which causes Hibernate to throw a deploy-time QuerySyntaxException. Remove the parentheses doesn't help; I left them in for clarity. Is there any way around this, or am I going to have to do this programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。您必须将属性值本身传递给查询:
You can't. You have to pass the property value itself to the query: