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"/>
</resultMap>
(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>
<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?
</resultMap>
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
</select>