最近我们已经从ibatis升级到mybatis。
我们使用ibatis queryformap方法返回Map对象。
由于它已升级到mybatis,我们正在使用releavant函数selectmap。
但它返回Map<key,Map<key,value>>
而不是Map<ky,value>
。
我的代码。
DAO.java
public Map<String, Date> getCoverageDateList(Long personId,
Date coverageEffectiveDate) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("personId", personId);
map.put("coverageEffectiveDate", coverageEffectiveDate);
return getDataAccessTemplate().selectMap("Quote.getCoverageDateList", map, "productType");
}
Quote.xml
<select id="getCoverageDateList" parameterType="java.util.Map" resultMap="coverageMap">
SELECT
distinct
ql.productType
,q.coverageEffectiveDate as coverageDate
FROM Coverage cv inner join Quote q on q.quoteId = cv.quoteid
inner join Quoteline ql on ql.lineid=cv.quotelineId
where
(cv.customerpersonid = #{personId} or cv.customerpersonid = @personId)
and (#{coverageEffectiveDate} between cv.rateEffectivedate and cv.rateTerminationDate)
</select>
<resultMap id="coverageMap" type="java.util.HashMap">
<result property="productType" column="productType"/>
<result property="coverageDate" column="coverageDate"/>
</resultMap>
有人可以帮忙。