Hibernate 集合链接
我有两个实体,
University
courses
Course
students
我想访问大学中的所有学生。我尝试了以下查询,
select u.courses.students from university u
但出现以下异常。
org.hibernate.QueryException: illegal attempt to dereference collection [university0_.id.courses] with element property reference [students] [ select u.courses.students from com.socialsite.persistence.University u ]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
.....
谁能解释一下这有什么问题吗?
I have two Entities
University
courses
Course
students
i want to access all the students in a university. I tried the following query
select u.courses.students from university u
i got the following exception.
org.hibernate.QueryException: illegal attempt to dereference collection [university0_.id.courses] with element property reference [students] [ select u.courses.students from com.socialsite.persistence.University u ]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:46)
.....
can anyone explain what is wrong with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,
u.courses
是一个集合,没有students
属性(这是单个Course
的属性)。Well,
u.courses
is a Collection and doesn't have astudents
property (which is a property of a singleCourse
).我想通了。谢谢帕斯卡
i figured it out. Thanks pascal