mapper文件中id命名最好首字母小写,避免让mybatis认为是一个类
<!--获取供应商列表-->
<resultMap id="ProviderList" type="Provider">
<result property="id" column="id"/>
<result property="proCode" column="proCode"/>
<result property="proName" column="proName"/>
<result property="proDesc" column="proDesc"/>
<result property="proContact" column="proContact"/>
<result property="proPhone" column="proPhone"/>
<result property="proAddress" column="proAddress"/>
<result property="creationDate" column="creationDate"/>
</resultMap>
<select id="getProviderList" parameterType="Provider" resultMap="ProviderList">
select * from smbms_provider provider
where proName like CONCAT('%', #{proName}, '%')
</select>
其中resultMap
的id名称为ProviderList
,会将ProviderList
理解为一个类,映射不到
<resultMap id="ProviderList" type="Provider">
<result property="id" column="id"/>
<result property="proCode" column="proCode"/>
<result property="proName" column="proName"/>
<result property="proDesc" column="proDesc"/>
<result property="proContact" column="proContact"/>
<result property="proPhone" column="proPhone"/>
<result property="proAddress" column="proAddress"/>
<result property="creationDate" column="creationDate"/>
</resultMap>
会发生异常,正确写法为将ProviderList
的首字母小写,即为避免问题mapper文件中id值小写