Thanks Michal.
   Larry and I worked through this yesterday. It's on the wiki now.
http://wiki.apache.org/ibatis/How_20do_20I_20get_20around_20the_20n_2b1_20selects_20problem_3f
 
    In short, it was a namespace issue. It was namespace aware but I didn't include the namespace. I thought it would default to the name space of the resultMap that required it.
-Tim


From: Michal Malecki [mailto:misiek_x@poczta.onet.pl]
Sent: Thursday, January 06, 2005 6:51 AM
To: ibatis-user-java@incubator.apache.org
Subject: Re: Incorrect usage of n+1 fix?

Shouldn't groupBy="name" be rather in the quarterMap? It is there, where the grouping happens.
Michał Małecki

Following the threads on the mailing list archive I tried to use the n+1 fix but I get the following from my query.
Below is the exception and the related items that I have defined.
It's interesting to note that if I don't try to execute getQuartersForServiceYear then it works fine (doesn't complain about missing maps etc).

Caused by: com.ibatis.sqlmap.client.SqlMapException: There is no result map named monthMap in this SqlMap.
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in sqlMap.xml.
 
  <resultMap id="quarterMap" class="calendarQuarter">
    <result property="quarter" column="quarter"/>
    <result property="name" column="name"/>
    <result property="description" column="description"/>
    <result property="months" resultMap="monthMap"/>
  </resultMap>
 
  <resultMap id="monthMap" class="calendarMonth" groupBy="name">
    <result property="name" column="monthName"/>
    <result property="description" column="monthDescription"/>
    <result property="broadcastStartDate" column="broadcastStartDate"/>
    <result property="broadcastEndDate" column="broadcastEndDate"/>
  </resultMap>
 
  <select id="getQuartersForServiceYear" resultMap="quarterMap">
    select
        distinct $serviceCode$QuarterNumber as quarter,
        $serviceCode$QuarterName as name,
        $serviceCode$QuarterDesc as description,
        $serviceCode$SeasonYear as year,
        $serviceCode$MonthName as monthName,
        $serviceCode$MonthDesc as monthDescription,
        min(broadcastDate) as broadcastStartDate,
        max(broadcastDate) as broadcastEndDate
    from BroadcastDate
    where $serviceCode$SeasonYear = #year#
    and $serviceCode$MonthName is not null
    group by
        $serviceCode$QuarterDesc,
        $serviceCode$QuarterNumber,
        $serviceCode$QuarterName,
        $serviceCode$SeasonYear,
        $serviceCode$MonthName,
        $serviceCode$MonthDesc
    order by broadcastStartDate
  </select>