Hibernate - 集合未填充所有子项
我在休眠期间遇到了一个非常奇怪的问题。
我们正在使用 Grails 和 GORM 来开发应用程序。
行为如下。 假设我有一个关系部门 ->雇员。 基本上假设我有 Dept.id=1,有 3 名员工,Dept.id=2,有 5 名员工。
我们正在尝试创建一个类似的查询。 检索employee.id = X的所有部门。
让它通过join/criteria或任何我们让查询工作的方式,但集合中填充的唯一子项是与id = X匹配的员工。
如果我这样做也没关系getSize 或其他什么,该集合永远不会填充真实数据,我的意思是其他 3 或 4 名员工。
这是一个非常奇怪的问题,说实话,我过去从未经历过。
任何帮助将不胜感激。
谢谢。
I have been having a very weird issue in hibernate.
We are using Grails and GORM to develop an application.
The behavior is the following.
Lets assume I have a relationship Department -> Employees.
Basically lets suppose I have Dept.id=1 which have 3 employees and Dept.id=2 which have 5 employees.
We are trying to create a query like.
Retrieve all the departments where employee.id = X.
Let it be via join/criteria or whatever we get the query working, but the only child populated in the collection is the employee that match the id = X.
It doesnt matter if I do a getSize or whatever, the collection never gets populated with the real data, I mean, the other 3 or 4 employees.
This is a very weird issue and to be honest, I never experienced it in the past.
Any help will be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过使用 Hibernate.initialise(proxy)?
初始化方法初始化代理对象。
Have you ever tried to use Hibernate.initialise(proxy)?
Initialise method inits the proxy object.
要查看发生了什么,请按照以下步骤操作:
To see what's going on, follow these steps: