tags:

views:

35

answers:

1

Hello

Let's say I have table foo, table bar, and table zoo. foo has a member bar and there is a one to one relationship between them. bar has a list and there is a one to many relationship between them.

the list is not initialized automatically when bar is read (ie it is lazy) Using hql I would like to get a list of the foo objects with zoo initialized in bar.

so something on the lines of:

select f from Foo f
left join fetch f.bar.zoo

this obviously throws an exception and I get that it's because the owner being returned is Foo and not Bar. Nonetheless I need Foo and not Bar and I need zoo to be initialized. Is there a way to do this in one query?

Thanks Jill

A: 

The following should work:

FROM Foo f
  LEFT JOIN FETCH f.bar b
  LEFT JOIN FETCH b.zoos
Pascal Thivent
tried but now I get a null pointer exception. on the second left join fetch.
Jill
@Jill Please show mappings allowing to reproduce. I tried with some entities and I get the expected result.
Pascal Thivent