I have a model with nested OneToMany , e.g., a Department with a list of Managers and a Manager with a list of Projects. They have the requiste four MTO and OTM mappings. Both OTM mappings specify eager fetch and cascade.ALL. There is referential integrity constraints on both relationships, eg the joinColumn in Project is an FK pointing to Manager etc.
A Manager returned by find(), is populated with a list of Projects as expected. Likewise a Department returned by find() is populated with a list of Managers. However, in the latter case, the project list(s) in those Manager entities is empty. This happens whether the Department entity is returned detached or managed. I have seen this in several different scenarios. Right now I'm testing remove() on a Department, which fails when the remove is cascaded to one of it's Managers, because it doesn't cascade and delete the projects (because the Manager's project list is not populated, as I would expect). I don't understand why it doesn't get populated, since it does if I do a direct find() on that Manager. I've also seen the same problem with queries. I wrote some code that walks the whole structure, fetching all the entities, and that is where I see the empty Project list in a Manager. In my real model there are more levels. I can't detect any particular pattern, such as only populating to a certain depth. Assuming I have everything correct, what could be causing this? -- View this message in context: http://openjpa.208410.n2.nabble.com/OneToMany-not-populated-unless-find-is-directly-on-parent-tp5714688p5714688.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
