Based on what you are asking I'm assuming you are quite new to programming.

What database are you using?
Have you researched if it has any facilities for handling XML? (i.e. Oracle)

iBATIS works with objects. So, it may be wise to parse the XML into Java POJOs and then save those object into the database. After that you can select the data out into the same POJOs.

Brandon Goodin

On Mon, Apr 14, 2008 at 9:09 AM, kiran vuppla <kirankumar_vuppla@yahoo.com> wrote:

I have an xml file and want to store in to an IBatis object. Please let me know if any one has any solution to write the SQL.

XML FILE:

<content>
  <talent>
    <image>/images/test1.gif</image>
    <imageAltText>testImageAltText</imageAltText>
    <links>
    <link>/urls/link1.html</link>
    <text>link1</text>
    </links>
    <links>
    <link>/urls/link2.html</link>
    <text>link2</text>
    </links>
   </talent>
  <talent>
    <image>/images/test2.gif</image>
    <imageAltText>testImageAltText2</imageAltText>
    <links>
    <link>/urls/link3.html</link>
    <text>link3</text>
    </links>
    <links>
    <link>/urls/link4.html</link>
    <text>link4</text>
    </links>
   </talent>
  </content>

IBATIS RESULT MUST BE:

   <resultMap class="com.test.domain.MainModule" id="MainModuleResultObject" groupBy="id">
    <result property="modules" resultMap="module.ModuleResults"/>
   </resultMap>

   <resultMap class="com.test.domain.Module" id="ModuleResults" groupBy="id">
      <result property="id" column="ID"/>
       <result property="titleImageURL" column="IMG_URL"/>
       <result property="titleImageAltText" column="IMG_ALT_TEXT"/>
       <result property="moduleElements" resultMap="module.ModuleElementResult"/>      
    </resultMap>

   <resultMap class="com.test.domain.ModuleElement" id="ModuleElementResult">
            <result property="link" column="LINK"/>
            <result property="text" column="TEXT"/>
    </resultMap>

 If some one can help me out in writing SQL to return the result in the above format that would be grateful.

 Thanks in advance for your time.
 Kiran