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 Darek Dober <do...@op.pl> on 2005/07/03 21:14:57 UTC

Avoiding N+1 selects

Hi
According to the documentation it is possible to ommit N+1 selects using
i.e:

<resultMap id="get-product-result" class="com.ibatis.example.Product">
<result property="id" column="PRD_ID"/>
<result property="description" column="PRD_DESCRIPTION"/>
<result property="category.id" column="CAT_ID" />
<result property="category.description" column="CAT_DESCRIPTION" />
</resultMap>

What if category has several attributes, I wouldn't like to recopy them to
other resultMap. Adding new attributes, requires
to place it in two or more resultMaps.
I would like just to reuse categoryMap from somewhere else.

Something like this on page 28 (resultMap):
<resultMap id="quarterMap" class="calendarQuarter" groupBy="quarter">
<result property="quarter" column="quarter"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<result property="months" resultMap="Calendar.monthMap"/>
</resultMap>

But according to the documentation calendarQuarter is expected to have get
and set methods for months, as a List,
I would like to have only one month of class calendarMonth

Example mentioned above, throws exception: ClastCastException, I suppose it
expects months to be List, but I would like it to be one CalendarMap

Is it possible, to point down, that I want only one Bean, not the List?

Regards
Darek Dober