MyBatis怎么进行三表联立查询啊

user表

图片说明

book表

图片说明

shopcart表

图片说明

三表联立关系

图片说明

user类

    private int user_id;
    private String user_name;
    private String user_account;
    private String user_pwd;
    private String user_time;
    private String user_icon;
    private String user_iphone;
    private String user_email;

book类

    private int book_id;
    private String book_name;
    private String book_author;
    private String book_into;
    private String book_img;
    private float book_price;
    private String book_time;

shopcart类

    private int cart_id;
    private int user_id;
    private int book_id;
    private int num;
    private User user;
    private Book book;

xml文件

    <select id="findCart" parameterType="shopCart" resultMap="shopCarts">
        SELECT user.user_id,book.*,shoppingcart.num FROM user,book,shoppingcart WHERE user.user_id = shoppingcart.user_id and book.book_id = shoppingcart.book_id AND user.user_id = #{user_id};
    </select>


<resultMap type="shopCart" id="shopCarts" >
    <id property="card_id" column="card_id"/>
    <result property="book_id" column="book_id"/>
    <result property="user_id" column="user_id"/>
    <collection property="book_id" ofType="book"/>
       <result property="book_name" column="book_name"/>
       <result property="book_author" column="book_author"/>
       <result property="book_into" column="book_into"/>
        <result property="book_img" column="book_img"/>
        <result property="book_price" column="book_price"/>
         <result property="book_time" column="book_time"/>
      </collection>

          <collection property="user" ofType="user">
          <id property="user_id" column="user_id"/>
         <result property="class_name" column="class_name"/>
          </collection>
   </resultMap>

报错

The element type "resultMap" must be terminated by the matching end-tag "</resultMap>".

那个xml文件该怎么写啊

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问