I have tried a few different paths to solve this, but am not able to find the answer. I have 2 tables, PARTY and EMAIL. I have hibernate mappings for these tables. However, I want to create another Bean in my system, calling it PartyInfo, with a mapping that only has select columns from the PARTY, EMAIL and others joined to PARTY via a PARTY_ID. The others, I have been able to the the properties I want using the <join> method. For EMAIL though, a party can have mulitple email addresses, and I want to get only the address (the String not the Email bean) of the primary email address. We can identify the primary by a flag in the EMAIL table.
So is it possible to get this one String via a join in the mapping?
I tried something like this in the Email.hbm.xml:
Code:
<properties name="primaryEmailReference">
<property name="isPrimary" column="IS_PRIMARY" type="true_false" length="1"/>
<many-to-one name="party" class="com.thomson.ecommerce.rebar.model.Party">
<column name="PARTY_ID" precision="12" scale="0" not-null="true" />
</many-to-one>
</properties>
and in my PartyInfo.hbm.xml:
Code:
<one-to-one name="primaryEmailAddress"
property-ref="primaryEmailReference">
<formula>'T'</formula>
<formula>PARTY_ID</formula>
</one-to-one>
But this gets me the Email object. I need would like to have the primaryEmailAddress property be only the string from the EMAIL_ADDRESS column so I don't have to convert it later (trying keep the object size as small as possible). Any thoughts on this?
K