You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Erica Cody <AI...@idpa.state.il.us> on 2006/04/05 21:51:59 UTC

Complex Collection Properties - groupBy parameter

Sorry for all the novice questions...I am just learning all this object relational mapping stuff.  I tried Hibernate, but it seems to be very complex and require extensive mapping to accomplish simple tasks.  Ibatis seems much simplier.  Anyway, I can't seem to find anything in the Wiki or mailinglist archives, so would appreciate your assistance on the proper use of the sql data mapper in regards to collection mapping.  


My object map is 
business
    myRole (Collection)
        person
        myAuthorizations(Collection)  

My SQL is 

select *
from business as a
inner join myRole as b on a.busId = b.busId
inner join person as c on b.myId = c.myId
left outer join empAuthorizations as d on b.myId = d.myId and b.busId = d.busId
where c.busId = ?


Both myRole and empAuthorizations have composite keys.  I assume I have to define resultMaps with groupBy clauses for both collections?

1.  What would be the proper way to define a composite key in the groupBy parameter of the resultMap?  I don't find anything in the developer's guide.  Is it {key1, key2} or is this even possible ??  

2.  Is it the database column name that goes there or the property name?  The guide uses the same name for both (e.g. quarter), so I'm not sure which one it wants.  

3.  In a single resultMap, can I map multiple column/alias names to the same property?  For example, if I was doing a simple select, I could use the table column name, but if I was doing a more complex select, I might have to give the column an alias name.  I would like to use/extend from one resultMap for both types of queries.  Is this possible?  

4.  Do I need to define the joining column(s) on the <result property="myAuthorizations" resultMap="MyAuths.myAuthResult"/> ?  I noticed this in the archives in an example of how to get the groupBy logic to work.  These are composite key, so again, is this possible or even required?  I do have composite key classes defined.  

Appreciate any help that you can give.  Regards.   :->