If I added a reference to Product from LocalizedProduct then it works with
this hql (added "or lp.Product is null":

"select distinct p from Product p left join fetch p.LocalizedProducts lp
where lp.CultureInfoName = :pSomeCulture or lp.Product is null"

Thanks again Fabio for pointing me to the right direction!

On Sun, Sep 6, 2009 at 4:06 PM, Martin Nilsson <[email protected]> wrote:

> Thanks Fabio.
>
> But do I get products that have no matching pSomeCulture (like the Truck
> product example below)? I tried this but didn't get that product.
>
>
>
> On Sun, Sep 6, 2009 at 3:43 PM, Fabio Maulo <[email protected]> wrote:
>
>> select distinct p from Product p left join fetch p.LocalizedProducts lp
>> where lp.CultureInfoName = :pSomeCulture
>>
>> 2009/9/6 Martin Nilsson <[email protected]>
>>
>> My domain model
>>>
>>> class Product
>>>   prop Title : string
>>>   prop LocalizedProducts : IList(of LocalizedProduct)
>>>
>>> class LocalizedProduct
>>>   prop CultureInfoName : string
>>>   prop Title : string
>>>
>>> Can anyone help me to create a query that selects the products and the
>>> localized product (if exists).
>>>
>>> So if I have this data:
>>>
>>> Product table
>>> id    Title
>>> 1     Car
>>> 2     Truck
>>>
>>> LocalizedProduct table
>>> id    Title   CultureInfoName Product_id
>>> 14    Bil     sv-SE           1
>>> 15    Auto    de-DE           1
>>>
>>>
>>> Then I should have these instances (note that "de-DE" is not loaded):
>>>
>>> Car
>>>   Id : 1
>>>   Title : Car
>>>   LocalizedProducts : { LocalizedProd { Id : 14, Title : Bil } }
>>>
>>> Truck
>>>   Id : 2
>>>   Title : Truck
>>>   LocalizedProducts : {}
>>>
>>> Any help is appreciated!
>>>
>>>
>>>
>>
>>
>> --
>> Fabio Maulo
>>
>> >>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to