Hello,

 

I am having problems trying to reference a resultMap defined in one namespace (xml mapping file) from another namespace (another xml mapping file). However, this works fine in the case of resultMapping.

 

For example:

 

I have 2 namespaces A and B described in A.xml and B.xml. The following mapping works fine for me

 

A.xml  

<sqlMap namespace="A">

                   <resultMap id="Aresult" class="A">

                             <result property="ID" column="ID" dbType="Int32" type="Int"/>

                             <result property="Name" column="Name"/>

                             <result property="Description" column="Description"/>    

<result property="BRef" resultMapping="B.Bresult"/>

                   </resultMap>

</sqlMap>

 

 

 B.xml

<sqlMap namespace="B">

                   <resultMap id="Bresult" class="B">                     

                             <result property="ID" column="BID" dbType="Int32" type="Int"/>

                             <result property="Name" column="Bname"/>

                   </resultMap>

</sqlMap>

 

 

But what if I want to do something like this

 

A.xml

<sqlMap namespace="A">

                   <resultMap id="Aresult" class="A">

                             <result property="ID" column="ID" dbType="Int32" type="Int"/>

                             <result property="Name" column="Name"/>

                             <result property="Description" column="Description"/>    

<result property="BList" column="ID" select="getBList" lazyLoad="true"/>

                   </resultMap>

 

 

</sqlMap>

 

<select id=" getBList " parameterClass="int" resultMap="B.Bresult">

          SELECT A.*, B.ID AS BID, B.Name AS Bname

          FROM A LEFT OUTER INNER JOIN B ON A.BrefID = B.ID

          WHERE A.ID=#value#

</select>

 

B.xml

<sqlMap namespace="B">

                   <resultMap id="Bresult" class="B">                     

                             <result property="ID" column="BID" dbType="Int32" type="Int"/>

                             <result property="Name" column="Bname"/>

                   </resultMap>

</sqlMap>

 

 

In the <select resultMap> I cannot point to a resultMap in another namespace, instead I have to duplicate the resultMap B in the A namespace.

This is the error I get:

 

IBatisNet.DataMapper.Exceptions.DataMapperException occurred

  Message="This SQL map does not contain an ResultMap named B.Bresult"

  Source="IBatisNet.DataMapper"

  StackTrace:

       at IBatisNet.DataMapper.SqlMapper.GetResultMap(String name)

 

 

I have already tried making useStatementNamespaces = true in the sqlMap.config without any success. This was suggested to me by a colleague who uses the java version of iBatis and he said this type of scenario works fine.

 

Is there any other way to achieve this? 

 

 

Thanks for your help,

 

J. Mirabal

 

 

 

 

 

CONFIDENTIALITY: This email (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this email in error, please notify the sender and delete this email from your system. Thank you.

Reply via email to