使用mybatis,在写映射文件mapping.xml 中的resultMap时,出现元素类型为 "resultMap" 的内容必须匹配 "(constructor?,id*,result*,association*,collection*,discriminator?)"
的错误,检查发现resultMap中元素的顺序应按照括号中内容的顺序,也就是id、result、association、collection、discriminatory,不能在result没写完的情况下插入association或者collection。
错误写法:
<resultMap id="baseResultMapWithUseableSeller" type="com.fuyun.common.model.CouponBatchMulti" extends="baseResultMap">
<id column="ID" property="id" jdbcType="INTEGER" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="TYPE" property="type" jdbcType="INTEGER" />
<result column="REMARK" property="remark" jdbcType="VARCHAR" />
<collection property="usebleSeller" ofType="com.fuyun.common.model.Seller">
<result column="SELLER_ID" property="id" jdbcType="INTEGER" />
<result column="SELLER_COMPANY_NAME" property="companyName" jdbcType="VARCHAR" />
</collection>
<result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
<result column="UPDATE_TIME" property="updateTime" jdbcType="TIMESTAMP" />
<result column="IS_DEL" property="isDel" jdbcType="INTEGER" />
</resultMap>
正确写法:
<resultMap id="baseResultMapWithUseableSeller" type="com.fuyun.common.model.CouponBatchMulti" extends="baseResultMap">
<id column="ID" property="id" jdbcType="INTEGER" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="TYPE" property="type" jdbcType="INTEGER" />
<result column="REMARK" property="remark" jdbcType="VARCHAR" />
<result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
<result column="UPDATE_TIME" property="updateTime" jdbcType="TIMESTAMP" />
<result column="IS_DEL" property="isDel" jdbcType="INTEGER" />
<collection property="usebleSeller" ofType="com.fuyun.common.model.Seller">
<result column="SELLER_ID" property="id" jdbcType="INTEGER" />
<result column="SELLER_COMPANY_NAME" property="companyName" jdbcType="VARCHAR" />
</collection>
</resultMap>