ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick <ric...@gmail.com>
Subject Am I missing something really simple? Way to avoid adding all props in a map if I decide to add one extra collection to pojo
Date Mon, 17 Nov 2008 15:56:51 GMT
Hopefully I'm just being a newb and missing something simple. It's
been a while since I worked with iBATIS:)...

My column names and pojo names are the same, so typically I don't even
need a result map created to map my properties (I can just map my
resultClass to the query). Where things break down though is if I want
to nest a collection of another object in one of my pojos. For example
in the code below BusinessEntity can have "Associates" so I've added a
List<Associate> field to my BusinessEntity pojo.  What I'd love to do
now is somehow get my BusinessEntity populated and the nested
Associate lists populated *WITHOUT* having to go through and declare
EVERY SINGLE property in a Map (since my fields match up fine to the
columns.) It seems though that I can't do this? Am I missing an easy
way to avoid this? I wish I could do something like:
 <!-- populated all properties on the BusinessEntity class if you can!!!! --->
<resultMap id="beMap2" class="BusinessEntity" groupBy="businessEntityID">
       <!-- directly map a *** resultClass !  ***--->
      <result property="associates" resultClass="BusinessEntity.assMap2"/>

(Is there a work around?)

Instead of the above I'm currently having to do:

 <!-- example poulating the Value Objects -->
<resultMap id="beMap2" class="BusinessEntity" groupBy="businessEntityID">
   <result property="businessEntityID" column="businessEntityID"/>
   <result property="name" column="name"/>

   ...// *** having to map all my other props?

 <result property="addressLine1" column="addressLine1"/>
   <result property="associates" resultMap="BusinessEntity.assMap2"/>

<resultMap id="assMap2" class="com.nielsen.ondp.persistence.model.Associate">
   <result property="firstName" column="firstName"/>
   <result property="lastName" column="lastName"/>

    ...// *** having to map all my other props?


the simple query:

<select id="findBEsWithAssociates2" resultMap="beMap2" cacheModel="beCache">
     SELECT be.*, a.*
     FROM NPPBusinessEntity be, NPPAssociate a
     WHERE a.businessEntityID = be.businessEntityID ORDER BY be.businessEntityID

View raw message