tenwit wrote:
You're not making enough use of the entity name. This is the process (roughly):
- Set up the entity-name attribute on both Loan and Lender classes.
- In all collections and associations referring to either of those class and where you want to be specific about which one you're referring to, do not use the class="" attribute. Use the entity-name="" attribute instead.
So the loans set in Lender needs to change, too.
Actually, if you look at my mapping I
was referring to Lender from a Loan by entity-name only. It's just that my entity names are the same as class names. I've changed it to be simpler and updated the association from Lender to Laon just in case, but the problem is still there. Here are the mappings:
<hibernate-mapping>
<union-subclass name="com.fanniemae.lacrs.examples.simplecrud.model.Loan" entity-name="Loan" table="loan" extends="com.fanniemae.lacrs.core.model.AbstractModelObject">
<!-- Properties -->
<property name="fannieMaeLoanNumber" type="string">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="fannie_mae_loan_number" length="50"/>
</property>
<property name="upb" type="big_decimal">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="upb" precision="10" scale="7"/>
</property>
<property name="interestRate" type="big_decimal">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="interest_rate" precision="10" scale="7"/>
</property>
<!-- Associations -->
<!--many-to-one name="lender" class="com.fanniemae.lacrs.examples.simplecrud.model.Lender" -->
<many-to-one name="lender" entity-name="Lender" >
<column name="Lender_id" not-null="true"/>
</many-to-one>
</union-subclass>
</hibernate-mapping>
and Lender
<union-subclass name="com.fanniemae.lacrs.examples.simplecrud.model.Lender" entity-name="Lender" table="lender" extends="com.fanniemae.lacrs.core.model.AbstractModelObject">
<!-- Properties -->
<property name="name" type="string">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="name" not-null="true"/>
</property>
<!-- Associations -->
<set name="loans" inverse="true">
<key>
<column name="Lender_id" not-null="true"/>
</key>
<one-to-many entity-name="Loan" />
</set>
</union-subclass>
So are you sure that it is supposed to work?