AugustLeo_cheng
AugustLeo_cheng
采纳率100%
2015-11-06 02:03

Mybatis 返回类型问题 list selectOne()

已采纳

报错:nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 17
我返回的类型明明就是list 为什么还是报这个错

这个是我Mapper的

    public List<RefusalCause> findPage(DefaultCriteria obj);

    public Long findPageCount(DefaultCriteria obj);

    public List<RefusalCause> refusalCause(DefaultCriteria obj);

这个是Mapper.xml

 <resultMap type="com.xxx.o2o.model.RefusalCause" id="refusalCause">
        <result property="refusalTime" column="refusalTime" />
        <result property="noStore" column="noStore" />
        <result property="idCheck" column="idCheck" />
        <result property="preRefuse" column="preRefuse" />
        <result property="noLocNoSecurity" column="noLocNoSecurity" />
        <result property="FNoSecurity" column="FNoSecurity" />
        <result property="MNoSecurity" column="MNoSecurity" />
    </resultMap>



    <select id="refusalCause" parameterType="com.xxx.o2o.model.RefusalCause"
        resultMap="refusalCause">
        select date_format(update_time,'%y-%m-%d') as refusalTime,
        sum(case
        when
        close_reason=1 then 1 else 0 end) as noStore,
        sum(case
        when
        close_reason=2 then 1 else 0 end) as idCheck,
        sum(case when
        close_reason=3 then 1 else 0 end) as preRefuse,
        sum(case when
        close_reason=5 then 1 else 0 end) as noLocNoSecurity,
        sum(case when
        close_reason=7 then 1 else 0 end) as FNoSecurity,
        sum(case when
        close_reason=8 then 1 else 0 end) as MNoSecurity
        from t_order_overview
        where order_id in (
        select order_id from t_order_history where
        1 = 1 and
        order_status = 10
        and
        <![CDATA[order_time  > '2015-10-12' ]]>
        and
        <![CDATA[order_time < '2015-10-22']]>)

        and is_close = '1' group by
        date_format(update_time,'%y-%m-%d')
    </select>

    <select id="findPage" parameterType="com.xxx.framework.pagination.DefaultCriteria"
        resultMap="refusalCause">
        select date_format(update_time,'%y-%m-%d') as refusalTime,
        sum(case
        when
        close_reason=1 then 1 else 0 end) as noStore,
        sum(case
        when
        close_reason=2 then 1 else 0 end) as idCheck,
        sum(case when
        close_reason=3 then 1 else 0 end) as preRefuse,
        sum(case when
        close_reason=5 then 1 else 0 end) as noLocNoSecurity,
        sum(case when
        close_reason=7 then 1 else 0 end) as FNoSecurity,
        sum(case when
        close_reason=8 then 1 else 0 end) as MNoSecurity
        from t_order_overview
        where order_id in (
        select order_id from t_order_history where
        1 = 1 and
        order_status = 10
        <if test="startTime !=null">
            and order_time &gt; #{startTime}
        </if>
        <if test="endTime !=null">
            and order_time &lt; #{endTime}
        </if>
        )and is_close = '1' group by
        date_format(update_time,'%y-%m-%d')
        order
        by
        refusalTime desc
        limit #{start},#{end}
    </select>
    <select id="findPageCount" parameterType="com.xxx.framework.pagination.DefaultCriteria"
        resultType="Long">
        select count(1)
        from t_order_overview
        where order_id in (
        select order_id
        from t_order_history where
        1 = 1 and
        order_status = 10
        <if test="startTime !=null">
            and order_time &gt; #{startTime}
        </if>
        <if test="endTime !=null">
            and order_time &lt; #{endTime}
        </if>
        )
        and is_close = '1' group by
        date_format(update_time,'%y-%m-%d')
    </select>

求助

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • AugustLeo_cheng AugustLeo_cheng 6年前

    我知道了 ,我count(1)传回来的是数组,我用了long接收

    点赞 1 评论 复制链接分享

相关推荐