在mybaits中,我使用了resultMap标签,但是出现了以下错误,应该是返回值的问题
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
<select id="findOrdersWithBook" parameterType="Integer" resultMap="OrdersWithBookResult">
select * from others where id=#{id}
</select>
<resultMap id="OrdersWithBookResult" type="Orders">
<id property="id" column="id"/>
<result property="user_id" column="user_id"/>
<result property="b_id" column="b_id"/>
<result property="amount" column="amount"/>
<collection property="bookList" column="id" ofType="com.itheima.po.Book"
select="BookMapper.findBookById">
</collection>
</resultMap>
你的标签是不是位置错了?还有接收的返回值是不是一个实体类,最怕你的数据库表中有相同的id
<resultMap id="OrdersWithBookResult" type="Orders">
<id property="id" column="id"/>
<result property="user_id" column="user_id"/>
<result property="b_id" column="b_id"/>
<result property="amount" column="amount"/>
<collection property="bookList" column="id" ofType="com.itheima.po.Book">
</collection>
</resultMap>
<select id="findOrdersWithBook" parameterType="Integer" resultMap="OrdersWithBookResult">
select * from others where id=#{id}
</select>
<result property="userId" column="user_id"/>
<result property="bId" column="b_id"/>