程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> mybatis-Mybatis 返回類型問題 list selectOne()

mybatis-Mybatis 返回類型問題 list selectOne()

編輯:編程綜合問答
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>

求助

最佳回答:


我知道了 ,我count(1)傳回來的是數組,我用了long接收

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved