开发者

Hibernate - Collection not populating all children

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 开发者_如何学Pythonvia 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.


Have you ever tried to use Hibernate.initialise(proxy)?

Initialise method inits the proxy object.


To see what's going on, follow these steps:

  1. Configure Hibernate to output the SQL it generates. See what its actually querying.
  2. If that doesn't help, up the server logging to DEBUG, and see what Hibernate spits out.
  3. If that still doesn't help, attach the Hibernate source to Eclipse and step debug.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜