You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Espenschied, Jim" <Ji...@ps.net> on 2006/10/18 17:58:01 UTC
Complex Object resultMap
I am trying to populate a complex object. I have included the resultMaps
below. iBatis builds out the object correctly except for the Physician
class. It leaves the supplier attribute as null in ProviderRelationship.
I added an attribute called hospitalID to Physician. When I uncomment
<!-- <result property="hospitalID" column="PNHSP#"/> --> ibatis will
populate Physician.
Why does it only work if I add this attribute? I would like to remove
the hospitalID attribute.
Any help would be greatly appreciated.
Thanks,
Jim
<resultMap id="patientEncounterResultMap"
class="hdi.domain.PatientEncounter" groupBy="accountNumber">
<result property="accountNumber"
column="PNACCT"/>
<result property="relationships"
resultMap="HIS.providerRelationshipResultMap"/>
<result property="patient"
resultMap="HIS.patientResultMap"/>
</resultMap>
<resultMap id="personPatientResultMap"
class="psc.domain.Person" groupBy="lastName, firstName">
<result property="lastName" column="HAPLNM"/>
<result property="firstName" column="HAPFNM"/>
</resultMap>
<resultMap id="patientResultMap" class="hdi.domain.Patient">
<result property="party"
resultMap="HIS.personPatientResultMap"/>
<result property="medicalRecordNumber"
column="PNMRC#"/>
</resultMap>
<resultMap id="providerRelationshipResultMap"
class="hdi.domain.ProviderRelationship">
<result property="client"
resultMap="HIS.patientResultMap"/>
<result property="supplier"
resultMap="HIS.physicianResultMap"/>
<result property="type" column="PNRELD"/>
</resultMap>
<resultMap id="personPhysicianResultMap"
class="psc.domain.Person">
<result property="lastName" column="PNDNAM"/>
<result property="firstName" column="PNDNAM"/>
</resultMap>
<resultMap id="physicianResultMap"
class="hdi.domain.Physician">
<result property="party"
resultMap="HIS.personPhysicianResultMap"/>
<!-- <result property="hospitalID" column="PNHSP#"/>
-->
</resultMap>
Re: Complex Object resultMap
Posted by Jeff Butler <je...@gmail.com>.
Done - IBATIS-357
Jeff Butler
On 10/18/06, Espenschied, Jim <Ji...@ps.net> wrote:
>
> Jeff,
>
>
>
> Please go ahead and submit the bug to JIRA since you already have a test
> for it.
>
>
>
> Thanks,
>
>
>
> Jim
>
>
>
RE: Complex Object resultMap
Posted by "Espenschied, Jim" <Ji...@ps.net>.
Jeff,
Please go ahead and submit the bug to JIRA since you already have a test
for it.
Thanks,
Jim
________________________________
From: Jeff Butler [mailto:jeffgbutler@gmail.com]
Sent: Wednesday, October 18, 2006 12:27 PM
To: user-java@ibatis.apache.org
Subject: Re: Complex Object resultMap
Interesting. I've verified this behavior that if a result map only
includes another nested result map, then this failure occurs.
Begs the question - why would you do this? Why not simply have the
ProviderRelationship class hold the Person class directly - without the
intermediate Patient class that has no other properties? Although I
suppose the Patient class could hold other properties that are filled in
at another time.
But this does seem like a bug. Feel free to file a JIRA ticket for it
so we don't forget - or I'll do it if you prefer. I have a small test
case that proves it. Let me know.
Jeff Butler
On 10/18/06, Espenschied, Jim <Ji...@ps.net> wrote:
I am trying to populate a complex object. I have included the resultMaps
below. iBatis builds out the object correctly except for the Physician
class. It leaves the supplier attribute as null in ProviderRelationship.
I added an attribute called hospitalID to Physician. When I uncomment
<!-- <result property="hospitalID" column="PNHSP#"/> --> ibatis will
populate Physician.
Why does it only work if I add this attribute? I would like to remove
the hospitalID attribute.
Any help would be greatly appreciated.
Thanks,
Jim
<resultMap id="patientEncounterResultMap"
class="hdi.domain.PatientEncounter" groupBy="accountNumber">
<result property="accountNumber"
column="PNACCT"/>
<result property="relationships"
resultMap="HIS.providerRelationshipResultMap"/>
<result property="patient"
resultMap="HIS.patientResultMap"/>
</resultMap>
<resultMap id="personPatientResultMap"
class="psc.domain.Person" groupBy="lastName, firstName">
<result property="lastName" column="HAPLNM"/>
<result property="firstName" column="HAPFNM"/>
</resultMap>
<resultMap id="patientResultMap" class="hdi.domain.Patient">
<result property="party"
resultMap="HIS.personPatientResultMap"/>
<result property="medicalRecordNumber"
column="PNMRC#"/>
</resultMap>
<resultMap id="providerRelationshipResultMap"
class="hdi.domain.ProviderRelationship">
<result property="client"
resultMap="HIS.patientResultMap"/>
<result property="supplier"
resultMap="HIS.physicianResultMap"/>
<result property="type" column="PNRELD"/>
</resultMap>
<resultMap id="personPhysicianResultMap"
class="psc.domain.Person">
<result property="lastName" column="PNDNAM"/>
<result property="firstName" column="PNDNAM"/>
</resultMap>
<resultMap id="physicianResultMap"
class="hdi.domain.Physician">
<result property="party"
resultMap="HIS.personPhysicianResultMap"/>
<!-- <result property="hospitalID" column="PNHSP#"/>
-->
</resultMap>
Re: Complex Object resultMap
Posted by Jeff Butler <je...@gmail.com>.
Interesting. I've verified this behavior that if a result map only includes
another nested result map, then this failure occurs.
Begs the question - why would you do this? Why not simply have the
ProviderRelationship class hold the Person class directly - without the
intermediate Patient class that has no other properties? Although I suppose
the Patient class could hold other properties that are filled in at another
time.
But this does seem like a bug. Feel free to file a JIRA ticket for it so we
don't forget - or I'll do it if you prefer. I have a small test case that
proves it. Let me know.
Jeff Butler
On 10/18/06, Espenschied, Jim <Ji...@ps.net> wrote:
>
> I am trying to populate a complex object. I have included the resultMaps
> below. iBatis builds out the object correctly except for the Physician
> class. It leaves the supplier attribute as null in ProviderRelationship. I
> added an attribute called hospitalID to Physician. When I uncomment <!--
> <result property="hospitalID" column="PNHSP#"/> --> ibatis will populate
> Physician.
>
>
>
> Why does it only work if I add this attribute? I would like to remove the
> hospitalID attribute.
>
>
>
> Any help would be greatly appreciated.
>
>
>
> Thanks,
>
>
>
> Jim
>
>
>
> <resultMap id="patientEncounterResultMap" class="
> hdi.domain.PatientEncounter" groupBy="accountNumber">
>
> <result property="accountNumber"
> column="PNACCT"/>
>
> <result property="relationships" resultMap="
> HIS.providerRelationshipResultMap"/>
>
> <result property="patient" resultMap="
> HIS.patientResultMap"/>
>
> </resultMap>
>
>
>
> <resultMap id="personPatientResultMap" class="
> psc.domain.Person" groupBy="lastName, firstName">
>
> <result property="lastName"
> column="HAPLNM"/>
>
> <result property="firstName" column="HAPFNM"/>
>
> </resultMap>
>
>
>
> <resultMap id="patientResultMap" class="hdi.domain.Patient">
>
>
> <result property="party" resultMap="
> HIS.personPatientResultMap"/>
>
> <result property="medicalRecordNumber"
> column="PNMRC#"/>
>
>
> </resultMap>
>
>
>
> <resultMap id="providerRelationshipResultMap" class="
> hdi.domain.ProviderRelationship">
>
> <result property="client" resultMap="
> HIS.patientResultMap"/>
>
> <result property="supplier" resultMap="
> HIS.physicianResultMap"/>
>
> <result property="type"
> column="PNRELD"/>
>
> </resultMap>
>
>
>
> <resultMap id="personPhysicianResultMap" class="
> psc.domain.Person">
>
> <result property="lastName"
> column="PNDNAM"/>
>
> <result property="firstName" column="PNDNAM"/>
>
> </resultMap>
>
>
>
> <resultMap id="physicianResultMap" class="hdi.domain.Physician">
>
>
> <result property="party" resultMap="
> HIS.personPhysicianResultMap"/>
>
> <!-- <result property="hospitalID" column="PNHSP#"/>
> -->
>
> </resultMap>
>