ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiran vuppla <kirankumar_vup...@yahoo.com>
Subject Multiple Sql Results from one ResultMap?
Date Fri, 15 Aug 2008 01:11:41 GMT
I
would like to set the properties of one result map from multiple
<select> statements. Is it possible to do as below? if we can
do I would like to know how to pass the parameters to the other select
statments? I would appreciate if some one can let me know.
 
<resultMap id="MainResult" class="Product">
 <result property="totalVal" column="TOTAL_VAL"/>
 <result property="totalAmt" column="TOTAL_AMT"/>
 <result property="totalProds" column="TOTAL_PRODS"/>
 <result property="maxVal" select="merchant.getMerchantMax"   />
 <result property="maxProds" select="merchant.getMerchantMaxInfo"  />
</resultMap>

<select id="getMerchantInfo" resultClass="string" parameterClass="map" resultMap="MerchantDistributionResult">
SELECT COUNT(*) as TOTAL_VAL
 , SUM(p.mathamount) as TOTAL_AMT
 , COUNT(distinct p.prods) AS TOTAL_PRODS
       FROM product p
       WHERE 
       AND p.proddate BETWEEN #startDate# AND #endDate# 
</select>
 
<select id="getMerchantMax" resultClass="string">
SELECT MAX(tbl.cnt1) as MAX_CNT
 from (
 SELECT COUNT(*) as cnt1
    FROM Merchant m
    where m.date BETWEEN to_date('12/25/2006','mm/dd/yyyy') AND to_date('12/30/2006','mm/dd/yyyy')

    GROUP BY round(m.date,'DD')) tbl;
</select>
 
<select id="getMerchantMaxInfo" resultClass="string">
SELECT MAX(tbl.cnt2) as MAX_PRODS 
 from (
  COUNT (distinct m.prods) as cnt2
    FROM merchant m 
    WHERE m.proddate BETWEEN to_date('12/25/2006','mm/dd/yyyy') AND to_date('12/30/2006','mm/dd/yyyy')

    GROUP BY round(m.date,'DD')) tbl;
</select>
 
Thanks,
KKV


      
Mime
View raw message