Working with composite keys and legacy database :)

We solved this problem by mapping each class without composite id and adding
where clause to each class mapping that works as a discriminator. In your
case this would look like this:

<class name="Region" where="ListName='Region'" table="Lists">
 <id name="Id" column="ListItemId" />
</class>

<class name="AddressType" where="ListName='AddressType'" table="Lists">
 <id name="Id" column="ListItemId" />
</class>

then this should work:
<many-to-one name="Region">
   <column name="RegionId" />
</many-to-one>

Don't try using subclass mappings with ListName as a discriminator as your
ids are only unique per subclass. (Don't ask how i know:))


On Mon, Jun 7, 2010 at 10:50 AM, Zeeshan Ali <[email protected]> wrote:

> Is it possible to avoid this_ on Hibernate generated queries ?
>



-- 
.
Maciej SzczepaƄski

-- 
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