mybatis collection two table field names with the same data are overwritten

Problem: Mybatis collection two table field names with the same data are overwritten
Solution : Take a different alias in SQL to distinguish it
Example:
<resultMap type="Desk" id="resultUserMap">
		<result property="DESK_ID" column="DESK_ID" />
		<result property="NAME" column="NAME" />
		<result property="REMARK" column="REMARK" />
		<collection property="books" ofType="Book" column="DESK_ID">
			<id property="BOOK_ID" column="BOOK_ID" />    
            <result property="NAME" column="bNAME"/>
            <result property="REMARK" column="bREMARK"/>   
            <result property="PRICE" column="PRICE"/>
		</collection>
	</resultMap>  

	<select id="getBooksByDesk" resultMap="resultUserMap" parameterType="String">
		SELECT d.DESK_ID,d.NAME,d.REMARK,b.BOOK_ID,b.NAME as bNAME,b.REMARK as bREMARK,b.PRICE
		FROM tb_desk d,tb_book b
		WHERE b.desk_id=d.desk_id AND d.desk_id=#{desk_id}
  	</select>

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326845276&siteId=291194637