I have a polymorphic one-to-many association using table-per-hierarchy strategy. While it is working fine for persisting the association, I am unable to fetch an association of the base class.
Hibernate version: 3.0.5
Mapping documents:
Code:
<class name="Coverage" table="elig_Cov" discriminator-value="0">
<id name="id" column="elig_Cov_Id" type="java.lang.Long">
<generator class="seqhilo">
<param name="sequence">elig_Cov_Id_Sq</param>
<param name="max_lo">10</param>
</generator>
</id>
<discriminator column="CovStyle_Cd" type="integer"/>
<property name="useServicePlan"
column="UseSrvPlan" type="integer"/>
<many-to-one name="subscription" column="elig_Sub_Id"
cascade="save-update" lazy="false"/>
<subclass name="ServiceTierCoverage" discriminator-value="1">
<many-to-one name="servicePlan" column="csm_SrvPlan_Id"
lazy="true" cascade="none"/>
<bag name="serviceTierCoverageTs" inverse="true" lazy="false"
outer-join="true" cascade="all-delete-orphan"
collection-type="org.hibernate.usertype.PeriodOfExistenceType">
<key column="elig_Cov_Id"/>
<one-to-many class="ServiceTierCoverageT"/>
</bag>
</subclass>
<subclass name="VendorTierCoverage" discriminator-value="2">
<many-to-one name="vendorPlan" column="csm_VdrPlan_Id"
cascade="none" lazy="false"/>
<bag name="vendorTierCoverageTs" inverse="true"
lazy="false" outer-join="true" cascade="all-delete-orphan"
collection-type="org.hibernate.usertype.PeriodOfExistenceType">
<key column="elig_Cov_Id"/>
<one-to-many class="VendorTierCoverageT"/>
</bag>
</subclass>
</class>
and the class with the association:
Code:
<class name="Subscription" table="elig_Sub">
<!-- other properties snipped -->
<set name="coverages" inverse="true" lazy="true"
cascade="all-delete-orphan">
<key column="elig_Cov_Id"/>
<one-to-many class="Coverage"/>
</set>
</class>
Again, persistence is working fine, but calling subscription.getCoverages() returns an empty set. I'm even using "left join fetch sub.coverages" in my HQL and it is still not resolving this relationship properly.
Name and version of the database you are using: Oracle 10g
Debug level Hibernate log excerpt:
Unfortunately, I ran into a bug with logging that has not yet been fixed in 3.0.5, so I can not turn on debug logging.
http://opensource.atlassian.com/project ... se/HHH-547