Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for ...

1.出现异常

Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.xc.dao.BookMapper.mapper_resultMap[BookBean]_association[category]

at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:782)
at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:754)
at org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:536)
at org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:207)
at org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:284)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.processNestedResultMappings(XMLMapperBuilder.java:383)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildResultMappingFromContext(XMLMapperBuilder.java:363)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:279)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:251)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:243)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116)

... 48 more

2.原始代码

<resultMap type="com.xc.domain.Book" id="BookBean">

<id column="book_id" property="book_id"/>
<result column="book_name" property="book_name"/>
<result column="category_id" property="category_id"/>
<result column="book_isbn" property="book_isbn"/>
<result column="orderPbook_idrice" property="book_autor"/>
<result column="book_autor" property="book_pubhouse"/>
<result column="book_page" property="book_page"/>
<result column="book_state" property="book_state"/>
<result column="book_inDate" property="book_inDate"/>
<result column="book_borrownum" property="book_borrownum"/>
<result column="others" property="others"/>
<!-- 多对一的关系 -->
<!--column:指外键值, property: 指的是属性的值, javaType:指的是属性的类型-->
<association property="category" javaType="com.xc.domain.Category">
<id column="category_id" property="category_id"/>
<result column="category_name" property="category_name"/>
<result column="category_case" property="category_case"/>
</association>
</resultMap>
<select id="bookFindAll" parameterType="QueryVo" resultType="BookBean">
select a.*,b.category_name from book a,category b where a.category_id = b.category_id
<!-- <include refid="user_Where"></include>
<if test="type != null and type != ''">
order by ${type} asc 
</if> -->

</select>

3.修改后代码

<resultMap type="com.xc.domain.Book" id="BookBean">
<id column="book_id" property="book_id"/>
<result column="book_name" property="book_name"/>
<result column="category_id" property="category_id"/>
<result column="book_isbn" property="book_isbn"/>
<result column="orderPbook_idrice" property="book_autor"/>
<result column="book_autor" property="book_pubhouse"/>
<result column="book_page" property="book_page"/>
<result column="book_state" property="book_state"/>
<result column="book_inDate" property="book_inDate"/>
<result column="book_borrownum" property="book_borrownum"/>
<result column="others" property="others"/>
<!-- 多对一的关系 -->
<!--column:指外键值, property: 指的是属性的值, javaType:指的是属性的类型-->
<association property="category" javaType="com.xc.domain.Category">
<id column="category_id" property="category_id"/>
<result column="category_name" property="category_name"/>
<result column="category_case" property="category_case"/>
</association>
</resultMap>
<select id="bookFindAll" parameterType="QueryVo" resultMap="BookBean">
select a.*,b.category_name from book a,category b where a.category_id = b.category_id
<!-- <include refid="user_Where"></include>
<if test="type != null and type != ''">
order by ${type} asc 
</if> -->
</select>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值