Considering the mappings below, a note can belong to two different types of owners. This is accomplished using a discriminator value.

Why is an additional where attribute required to apply the discriminator when another class has a set of a discriminated subclass?

This is my third mention of this issue. No one seems to respond! I don't know if I'm being unclear. I'll take a look at fixing it and submitting a patch if it's not desired functionality, but I'm wondering if it works this way intentionally or if it is an oversight.

Thanks for your help!
Jenica Humphreys
MountainView Software


//----------------- CONTACT MAPPING -------------------------------- <class name="Note" table="RM_Note" discriminator-value="99" > <id column="note_id" length="10" name="id" type="long" unsaved-value="null" > <generator class="identity" /> </id>

<discriminator column="owner_type_cd" type="int" force="true"/>

<property column="title_txt" length="50" name="titleTxt" type="string"/>
<property column="note_userid" length="10" name="userid" type="string"/>

<subclass name="ClaimNote" discriminator-value="0">
  <many-to-one name="claim" column="owner_id"/>
</subclass>

<subclass name="ContactNote" discriminator-value="2">
  <many-to-one name="contact" column="owner_id"/>
</subclass>

</class>

//----------------- CONTACT MAPPING --------------------------------
<class name="Contact" table="RM_CONTACT">
  <id name="contactId" type="long" column="contact_id" unsaved-value="null">
    <generator class="identity" />
  </id>

  <property name="firstName" column="first_name" length="15" type="string"/>
  <property name="lastName" column="last_name" length="15" type="string"/>

  <set name="notes" cascade="all" where="owner_type_cd=2" >
    <key column="owner_id" />
    <one-to-many class="ContactNote"/>
  </set>
</class>

//------------------ CLAIM MAPPING ----------------------------------
<class name="Claim" table="RM_CLAIM">
  <id name="claimId" type="long" column="claim_id" unsaved-value="null">
    <generator class="identity" />
  </id>

  <property name="claimNbr" column="claim_nbr" length="15" type="string"/>
  <property name="referenceNbr" column="ref_nbr" length="15" type="string"/>

  <set name="notes" cascade="all" where="owner_type_cd=0" >
    <key column="owner_id" />
    <one-to-many class="ClaimNote"/>
  </set>
</class>



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to