I have a simple abstract class with two subclasses. Another class has a one-to-many association with one of the subclasses - mapping files below.
When I retrieve instances of SPVShareholderHO from my code hibernate correctly retrieves using type='SHAREHOLD' in the query.
However, when hibernate retrieve the Set of shareholders from the CounterpartyHO, it does not have type='SHAREHOLD' in the query. Am I doing something wrong? Why does it behave this way?
Thanks in advance for any help.
<hibernate-mapping>
<class table="cp_subcounterparties" name="com.foo.dealframework.dao.impl.hibernate.model.EntityOwnerHO">
<id name="id">
<generator class="native"/>
</id>
<discriminator type="string" column="type" length="10"/>
<property name="touched" insert="false" column="touched" update="false"/>
<many-to-one column="cp_id" lazy="false" name="counterparty" class="com.foo.dealframework.dao.impl.hibernate.model.CounterpartyHO"/>
<many-to-one column="sub_cp_id" lazy="false" name="subCounterparty" class="com.foo.dealframework.dao.impl.hibernate.model.CounterpartyHO"/>
<property name="share" column="percentage"/>
<property name="managementCode" column="management_code"/>
<subclass name="com.foo.dealframework.dao.impl.hibernate.model.DealStakeholderHO" discriminator-value="WATERFALL"/>
<subclass name="com.foo.dealframework.dao.impl.hibernate.model.SPVShareholderHO" discriminator-value="SHAREHOLD"/>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class table="counterparty" name="com.foo.dealframework.dao.impl.hibernate.model.CounterpartyHO">
<id name="id">
<generator class="native"/>
</id>
<property name="name" column="name"/>
<set lazy="false" inverse="true" name="shareholders">
<key column="cp_id" not-null="true"/>
<one-to-many class="com.foo.dealframework.dao.impl.hibernate.model.SPVShareholderHO"/>
</set>
</class>
</hibernate-mapping>
|