Hello folks,

 

I’m fairly new to iBatis. Currently writing a data access prototype based on iBatis (for .Net, Data Mapper 1.5, Data Access 1.8, revision 419277). As example I’m writing a demo ASP.NET application to use the data access layer. While working with it I found a couple of issues/questions I would like to share.

 

1-       IBatisNet.DataAccess.Configuration.DomDaoManagerBuilder.GetProviders and IBatisNet.DataMapper.Configuration. DomSqlMapBuilder

 

In both cases, the invocation xmlProviders = Resources.GetConfigAsXmlDocument(PROVIDERS_FILE_NAME) doesn’t work for me. I had to change it with xmlProviders = Resources.GetResourceAsXmlDocument(PROVIDERS_FILE_NAME) and then it works. Any ideas?

 

2-       Leaving a reference to another class as Null when no value is retrieved from the database. For example, consider this mapping

 

          <resultMaps>

                   <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="A.Bresult"/>

                   </resultMap>

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

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

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

                   </resultMap>

          </resultMaps>

 

          <statements>

                   <select id="getA" resultMap=" Aresult ">

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

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

                   </select>     

          </statements>

 

          In case when there’s no reference to B for a particular instance of A, after reading de data executing “getA” an instance of B is created anyways. Then, none of its properties are populated (left as Null). Why not leaving A.BRef as Null instead? I mean, instead of getting A.BRef.ID=Null, A.BRef.Name=Null, it should be better to get A.BRef=Null

 

3-       Is it possible to point a <select> to a resultMap that is in another namespace (XML mapp)? For example, I can do

 

 

<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>

 

 

<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?

 

<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>

 

<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 (gives me an error), instead I have to duplicate the resultMap B in the A namespace. Is there any other way to achieve this?   

 

4-       Is it possible to support ISet collections (from Iesi.Collections) for leazyLoad the same way IList is supported?

 

 

Thanks for your patience reading all this.

 

 

J. Mirabal

 

 

 

 

Jesus Mirabal • Senior Architect • SunGard • Investran • 11098 Biscayne Boulevard, Suite 403Miami, FL  33161
Tel 305 891 3300 x 226 • Fax 305 895 0005 • www.sungard.com/investran

 

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