I don't think that this is currently possible. I don't really mind writing
result maps, as I'm generating most
of them with abator.
If you really need this feature feel free to create a jire issue and attach a
patch against the current iBATIS
trunk to it.
Regards
Kai
--- Original Nachricht ---
Absender: Rick
Datum: 18.11.2008 17:22
> I sent this tot he wrong list before, so I'm resending it. I think it
> would be a huge plus for ibatis. I don't mind digging into the source
> code... would it be a really tough fix? To modify result maps to allow
> them being based on result classes? Has this been brought up before.
> Just curious.
>
> To sum up if you don't read the original email - I can easily get this
> back in one query and notice how I don't need every property mapped.
> (The current way, you need an Address map of every property and and
> Associate with every property, when all I want to do is map up the
> column names directly to the objects)
>
> <!-- populated all properties on the BusinessEntity class if you can,
> without mapping them !!!! --->
> <resultMap id="beResult" class="BusinessEntity" groupBy="businessEntityID">
> <!-- directly map *** resultClasses not maps ! ***--->
> <result property="associates" resultClass="BusinessEntity"/>
> <result property="address" resultClass="Address"/>
> </resultMap>
>
> for:
> BusinessEntity {
> String name;
> String abbreviation;
> Integer id;
> //..etc
> Address address
> List<Associate> associates
> }
>
>
> On Mon, Nov 17, 2008 at 10:56 AM, Rick <[EMAIL PROTECTED]> wrote:
>> 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"/>
>> </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>
>>
>
>
>