ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Landry Soules <landry.p.sou...@gmail.com>
Subject Re: redundancy in resultmap declaration ?
Date Tue, 07 Nov 2006 19:36:46 GMT
Thank you  for the answer Larry, but can you please be more explicit, as 
i don't know how to achieve this....

Where to include country.resultmap in my code ?

<sqlMap namespace="address" >


  <resultMap id="result-address" class="com.seenxl.model.Address" >
       <result column="id" property="id" jdbcType="INTEGER" />
    <result column="add1" property="add1" jdbcType="VARCHAR" />
    <result column="add2" property="add2" jdbcType="VARCHAR" />
    <result column="city" property="city" jdbcType="VARCHAR" />
    <result column="zip_code" property="zipCode" jdbcType="VARCHAR" />
    <result column="country" property="country"
select="address.getCountry" />
    <result column="state" property="state" jdbcType="INTEGER" />
  </resultMap>
......

  <select id="getCountry" parameterClass="string"
resultMap="country.result-country">
select * from country where id = #value#
</select>
....

</sqlMap>


Larry Meadors a écrit :
> Include the result maps before including the mapped statements.
>
> This is sort of a minibug that we haven't gotten around to fixing,
> because it hasn't been to hard to work around. ;-)
>
> Larry
>
>
> On 11/5/06, Landry Soules <landry.p.soules@gmail.com> wrote:
>> Hello,
>>
>> Regarding complex properties, is there a way to declare only once the
>> corresponding resultmap ?
>>
>> Example :   an Address class and a Country class.
>>
>>
>> In country_SqlMap.xml i have :
>>
>> <sqlMap namespace="country" >
>>  <resultMap id="result-country" class="com.seenxl.model.Country" >
>>
>>     <result column="id" property="id" jdbcType="CHAR" />
>>     <result column="iso3" property="iso3" jdbcType="CHAR" />
>>     <result column="name" property="name" jdbcType="CHAR" />
>>     <result column="num_code" property="numCode" jdbcType="SMALLINT" />
>>     <result column="printable_name" property="printableName"
>> jdbcType="CHAR" />
>>   </resultMap>
>>   ...
>>
>> In address_SqlMap.xml :
>>
>> <sqlMap namespace="address" >
>>
>>
>>   <resultMap id="result-address" class="com.seenxl.model.Address" >
>>        <result column="id" property="id" jdbcType="INTEGER" />
>>     <result column="add1" property="add1" jdbcType="VARCHAR" />
>>     <result column="add2" property="add2" jdbcType="VARCHAR" />
>>     <result column="city" property="city" jdbcType="VARCHAR" />
>>     <result column="zip_code" property="zipCode" jdbcType="VARCHAR" />
>>     <result column="country" property="country"
>> select="address.getCountry" />
>>     <result column="state" property="state" jdbcType="INTEGER" />
>>   </resultMap>
>>
>> In order to map getCountry with its result, i would like to refer to the
>> result map defined in country_SqlMap.xml, like this :
>>
>>   <select id="getCountry" parameterClass="string"
>> resultMap="country.result-country">
>> select * from country where id = #value#
>> </select>
>>
>> But i get an error :
>>
>> ...
>> Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.
>> Cause: java.lang.RuntimeException: Error parsing XPath
>> '/sqlMap/select'.  Cause: com.ibatis.sqlmap.client.SqlMapException:
>> There is no result map named country.result-country in this SqlMap.
>>     at com.seenxl.persistence.DaoConfig.<clinit>(DaoConfig.java:40)
>>     ... 14 more
>>
>> So i have to copy country.result-country in address_SqlMap.xml...
>>
>> What is the way to use a resultMap outside of its sqlmap ?
>>
>


Mime
View raw message