Error instantiating class java.lang.Integer with invalid types () or values (). Cause: java.lang.NoSuchMethodException: java.lang.Integer.()
1.背景:mybatis中collection的column传入多个参数值时,报错
2. 解决:
你一对多关系中的一实体类,对应的Mapper.xml中,sql方法的parameterType一定要是map形式
错误配置:
一:
<select id="queryCitysByProId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
多:
<collection property="cityList"
ofType="com.jd.lean.mjp.dal.entity.City"
select="com.jd.lean.mjp.dal.mapper.CityMapper.queryCitysByProId"
column="{ppid = ProID}"
/>
正确配置
一:
<select id="queryCitysByProId" parameterType="java.util.Map" resultMap="BaseResultMap">
多:
<collection property="cityList"
ofType="com.jd.lean.mjp.dal.entity.City"
select="com.jd.lean.mjp.dal.mapper.CityMapper.queryCitysByProId"
column="{ppid = ProID}"
/>