1
回答
分页错误,The error occurred while setting parameters
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

@miemiedev 你好,想跟你请教个问题:

### The error occurred while setting parameters

### SQL: select * from a where a.STATUS IN   <foreach collection="couponStatusSet" item="item" index="index"    open="(" close=")" separator=",">    ?   </foreach> limit ?
### Cause: java.lang.reflect.UndeclaredThrowableException

我的开发环境是  spring+mybatis+mysql

<!-- Data access -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
</dependency>

sql:

<!-- 查询我的券信息 -->
<select id="searchMyCoupon" resultType="QueryCouponInfoDto"
resultMap="queryCouponInfoResultMap" parameterType="map">
<![CDATA[
select a.COUPON_NO
,b.COUPON_RULE_NAME
,a.REMAINING_AMOUNT
,a.START_TIME
,a.END_TIME
,case when a.STATUS=1 then '1'
when a.STATUS=2 then '1'
when a.STATUS=3 then '1'
when a.STATUS=6 then '1'
when a.STATUS=4 then '0'
when a.STATUS=5 then '0'
when a.END_TIME &lt;=NOW() then 0 end as ENABLED
FROM COUPON_INFO as a INNER JOIN COUPON_RULE as b on a.COUPON_RULE_CODE=b.COUPON_RULE_CODE
WHERE a.MEMBER_ID=#{member_id}
AND a.ISACTIVE='Y'
AND a.STATUS IN
<foreach collection="couponStatusSet" item="item" index="index"
open="(" close=")" separator=",">
#{item}
</foreach>
]]>
</select>


List<QueryCouponInfoDto> searchMyCoupon(Map<String,Object> paramMap,PageBounds pageBounds);


DAO层方法

-------------

List<QueryCouponInfoDto> searchMyCoupon(String memberId,Set<Integer> statusSet,PageBounds pageBounds);

impl实现类

@Override
public List<QueryCouponInfoDto> searchMyCoupon(String memberId, Set<Integer> statusSet,PageBounds pageBounds)
{
if (StringUtil.isEmpty(memberId)) {
return Collections.emptyList();
}


List<QueryCouponInfoDto> queryCouonInfoDtoList = null;
try {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("member_id", memberId);
paramMap.put("couponStatusSet", statusSet);


queryCouonInfoDtoList = couponMapper.searchMyCoupon(paramMap,pageBounds);
} catch (DataAccessException e) {
throw new BaseException("PES-DAO-CouponDaoiImpl.searchMyCoupon", e);
}


return queryCouonInfoDtoList;
}



<无标签>
举报
yahoo12345
发帖于2年前 1回/3K+阅
顶部