Oh, You've just sent solution :) I should had refresh nabble page before i've
post my message :)
Beniamin
Jacek Laskowski wrote:
>
> On Nov 27, 2007 3:45 PM, Tomasz Mazan <[EMAIL PROTECTED]> wrote:
>
>> 1) if I use query like
>>
>> @NamedQueries({
>> @NamedQuery(name = "ProductWithDeps",
>> query = "SELECT p FROM Product p"
>> + " WHERE p.number = :number")
>> })
>> product is found and returned, but if I use query like:
>>
>> 2)
>> @NamedQueries({
>> @NamedQuery(name = "ProductWithDeps",
>> query = "SELECT p FROM Product p"
>> + " join fetch p.blocks"
>> + " WHERE p.number= :number")
>> })
>> I get null as a finder result. What's wrong ?
>
> Most likely the entity doesn't have any blocks and thus the query
> returns null (p.blocks evaluates to null, and the query returns only
> entities that have at least one block in them - it's how INNER join
> works). Add LEFT before JOIN FETCH and it should work as expected.
>
> @NamedQueries({
> @NamedQuery(name = "ProductWithDeps",
> query = "SELECT p FROM Product p"
> + " LEFT JOIN FETCH p.blocks"
> + " WHERE p.number= :number")
> })
>
> Jacek
>
> --
> Jacek Laskowski
> http://www.JacekLaskowski.pl
>
>
--
View this message in context:
http://www.nabble.com/Force-to-load-subobjects-in-OpenJPA-tf4876000s134.html#a13972749
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.