Hibernate - 在标准之后设置投影
为什么这是不可能的?
Criteria crit1 = sess.createCriteria(Criteria1Class.class);
Criteria crit2 = crit1.createCriteria("criteria2Class");
crit2.setProjection(Projections.groupProperty("criteria2Property"));
List<String> l2 = crit2.list();
如果我使用这种构造,我会收到错误:
could not resolve property: criteria2Property of: com.foo.bar.models.Criteria1Class
offcourse criteria2Property does not believe in Criteria1Class
,因为它存在于Criteria2Class
那么为什么这个groupProperty
不存在可以在从 Criteria1Class
到 Criteria2Class
的 @manyToOne
关联上吗?
why is this not possible?
Criteria crit1 = sess.createCriteria(Criteria1Class.class);
Criteria crit2 = crit1.createCriteria("criteria2Class");
crit2.setProjection(Projections.groupProperty("criteria2Property"));
List<String> l2 = crit2.list();
If I use this construction I get the error:
could not resolve property: criteria2Property of: com.foo.bar.models.Criteria1Class
offcourse criteria2Property doesn't exist in Criteria1Class
because it exist in Criteria2Class
So why is this groupProperty
not possible on the @manyToOne
associations from Criteria1Class
to Criteria2Class
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了:
Solved it myself: