Maybe the empty property attribute works in iBATIS resultMaps. I haven't
tried it but it would result in your policySrcResult object properties
busEntity and yrsInBus to be setted again (twice) with the same values
has in policyDetail.
<resultMap id="policySrcResult" class="Policy">
<result column="POLICY_NUMBER" property="policyNumber"
jdbcType="VARCHAR" />
<result column="POL_TYPE" property="polType" jdbcType="VARCHAR" />
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR"
/>
<result property=""
column="{polType=POL_TYPE,policyNumber=POLICY_NUMBER}"
select="getPolicyDetail"/>
</resultMap>
<resultMap id="policyDetailResults" class="Policy">
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR" />
<result column="BUSINESS_ENTITY" property="policyDetail.busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="policyDetail.yrsInBus"
jdbcType="VARCHAR" />
</resultMap>
If this gives you the correct result, consider removing these lines from
policySrcResult resultMap.
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR"
/>
Christian
________________________________
From: Angel Braasch [mailto:ABRAASCH@fcci-group.com]
Sent: Friday, 15 September 2006 14:15
To: user-java@ibatis.apache.org
Subject: RE: Remap resultMap
Thank you for the reply.
When I tried the below I got an error that BUSINESS_ENTITY is not a
property of policyDetail. I changed it to busEntity, but I didn't get
the results I was looking for.
Maybe I'm not explaining this well. I want to take the results of the
below policyDetail property (which includes busEntity,yrsInBus) and
re-assign them to policySrcResults' busEntity and yrsInBus properties.
<resultMap id="policySrcResult" class="Policy">
<result column="POLICY_NUMBER" property="policyNumber"
jdbcType="VARCHAR" />
<result column="POL_TYPE" property="polType" jdbcType="VARCHAR" />
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR"
/>
<result property="policyDetail"
column="{polType=POL_TYPE,policyNumber=POLICY_NUMBER}"
select="getPolicyDetail"/>
</resultMap>
Thanks again for any assistance.
Angel
________________________________
From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca]
Sent: Friday, September 15, 2006 1:50 PM
To: user-java@ibatis.apache.org
Subject: RE: Remap resultMap
Try this.
<resultMap id="policySrcResult" class="Policy">
<result column="POLICY_NUMBER" property="policyNumber"
jdbcType="VARCHAR" />
<result column="POL_TYPE" property="polType" jdbcType="VARCHAR" />
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR"
/>
<result property="policyDetail.BUSINESS_ENTITY"
column="BUSINESS_ENTITY"/>
<result property="policyDetail.YRS_IN_BUS" column="YRS_IN_BUS"/>
</resultMap>
Christian
________________________________
From: Angel Braasch [mailto:ABRAASCH@fcci-group.com]
Sent: Friday, 15 September 2006 13:41
To: user-java@ibatis.apache.org
Subject: RE: Remap resultMap
I've been using IBATIS only for a short time....so I apologize if this a
newbie question. Can anyone help me with this posting?
Angel
________________________________
From: Angel Braasch [mailto:ABRAASCH@fcci-group.com]
Sent: Wednesday, September 13, 2006 12:33 PM
To: user-java@ibatis.apache.org
Subject: Remap resultMap
I have a policy object that is getting mapped in a resultMap. In that
resultMap I have to run another query to get additional properties.
This is a 1:1 situation. I want to remap those additional
properties(from policyDetailResults) back to the original
resultMap(policySrcResult).
I have tried to point "getPolicyDetail" to resultMap="policySrcResult"
remapResults="true". But then I got an Invalid column name on my
policyNumber field.
I'm at a loss on how to do this. Below are code snippets.
Any assistance would be greatly appreciated.
Thanks,
Angel
public class Policy{
private Policy policyDetail = null;
private String busEntity;
private String yrsInBus;
private String policyNumber = null;
private String polType = null;
getters/setters.....
}
<resultMap id="policySrcResult" class="Policy">
<result column="POLICY_NUMBER" property="policyNumber"
jdbcType="VARCHAR" />
<result column="POL_TYPE" property="polType" jdbcType="VARCHAR" />
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR"
/>
<result property="policyDetail"
column="{polType=POL_TYPE,policyNumber=POLICY_NUMBER}"
select="getPolicyDetail"/>
</resultMap>
<resultMap id="policyDetailResults" class="Policy">
<result column="BUSINESS_ENTITY" property="busEntity"
jdbcType="VARCHAR" />
<result column="YRS_IN_BUS" property="yrsInBus" jdbcType="VARCHAR" />
</resultMap>
<select id="getPolicyDetail" parameterClass="Policy"
resultMap="policyDetailResults">
SELECT BUSINESS_ENTITY, YRS_IN_BUS
FROM
<dynamic>
<isEqual property="polType" compareValue="N"> CPP_DETAIL </isEqual>
<isEqual property="polType" compareValue="U"> UMB_DETAIL </isEqual>
<isEqual property="polType" compareValue="Q"> UMB_FARM_DETAIL
</isEqual>
<isEqual property="polType" compareValue="X"> CA_DETAIL </isEqual>
<isEqual property="polType" compareValue="B"> BOPS_DETAIL
</isEqual>
<isEqual property="polType" compareValue="F"> CPP_FARM_DETAIL
</isEqual>
</dynamic>
WHERE POLICY_NUMBER=#policyNumber#
</select>
|