ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Vinson <vinson.li...@charter.net>
Subject Xml Result Mapping
Date Mon, 08 Aug 2005 15:04:28 GMT
Hi guys,

First off, sorry if you get this email twice, I sent the first from an
un-subscribed email address.   Secondly, iBatis rocks!

I'm fairly new to iBatis, but I really dig it so far.  It's been a breeze to
get result set -> pojo mapping for complex objects, but I'm having a bit of
a tough time getting the same complex objects to map to xml.  I'm hoping you
guys could provide some pointers, since I've not found much info on the
internet regarding this.

Here's the rundown:

I have a pojo like so:

public class Entity {

    private String entityClass;
    private String entityClassId;
    private long id;

      private List attributes;

      private List relationshipsOut;
    private List relationshipsIn;

      /** all getters and setters **/

And in my mapping file I have the following for the pojo mapping:

<resultMap class="Entity" id="entity-map" >

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

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

  <result property="entityClassId" column="classid"/>

  <result property="attributes" column="id"

  <result property="relationshipsOut" column="id"

  <result property="relationshipsIn" column="id"


<select id="getEntityById" resultMap="entity-map">
      select i.entityid as id, e.name as entityClass, i.classid as classid

        from EntityClassification i, EntityClass e
        where i.classid=e.id and i.entityid=#value#

<!-- the other subselects are left out for brevity -->

I am aware that I can change the resultClass to "xml" for the Entity, but
how can I get the sub-select elements (the three lists) to map to xml all at

Thanks for a great tool,

View raw message