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 ?

Reply via email to