I have an N+1 problem but it is on a relationship further down the object
hierarchy. I have the following objects:
- Plan
- RoundingRule
- RoundingItems
A Plan has a single (1:1) relationship with a RoundingRule (RoundingRule
property) and this then has a number of RoundingItems (1:N) (Roundings
collection IList).
My select statement is as follows:
select p.PlanId, …
rr.RoundingRuleId, …
ri.RoudingItemId, …
from Plan p
inner join RoundingRule rr on p.RoundingRuleId = rr.RoundingRuleId
inner join RoundingItem ri on rr.RoundingRuleId = ri.RoundingRuleId
where p.PlanId = #planId#
My resultmaps are as follows:
<resultMap id="PlanResult" class="Plan">
<result property="PlanId" column="PlanId"/>
…
<result property=" RoundingRule"
resultMapping="Plan.RoundingRuleResult"/>
</resultMap>
<resultMap id="RoundingRuleResult" class="RoundingRule">
<result property="RoundingRuleId" column="RoundingRuleId"/>
…
<result property=" Roundings"
resultMapping="Plan.RoundingItemResult"/>
</resultMap>
<resultMap id=" RoundingItemResult" class="RoundingItem">
<result property=" RoundingItemId" column="RoundingItemId"/>
…
</resultMap>
I cannot however get the N RoudingItem’s to load even with trying various
combinations of groupBy="Id" on the resultmaps. If a groupBy is specified on
the RoundRuleResult resultmap then I get a casting error trying to cast
RoundingRule to an IList.
Can this be done? If so how? Any help appreciated.
--
View this message in context:
http://www.nabble.com/N%2B1-sort-of--tp16977872p16977872.html
Sent from the iBATIS - User - Cs mailing list archive at Nabble.com.