mybatis There is no getter for property named ‘*‘ in ‘class java.lang.String

mybatis There is no getter for property named 'car_port_ids' in 'class java.lang.String
出现这种错误我这边是mapper.xml子查询字段不对导致的
我把查询结果的列的字段放进去结果不识别car_port_ids可能我这种字段本身就有问题
技术博客 http://idea.coderyj.com/

1.解决

<resultMap id="BaseResultMap" type="com.cspid.entity.SysDevice">
        <id column="id" jdbcType="VARCHAR" property="id"/>
        <result column="line_id" jdbcType="VARCHAR" property="lineId"/>
        <result column="car_port_ids" jdbcType="VARCHAR" property="carPortIds"/>
        <result column="power_state" jdbcType="VARCHAR" property="powerState"/>
        <result column="charge_model_id" jdbcType="VARCHAR" property="chargeModelId"/>
        <result column="park_name" jdbcType="VARCHAR" property="parkName"/>
        <collection property="carportList" select="selectCarportList"
                    column="{carPortIds=car_port_ids}" ofType="com.cspid.entity.SysCarport" javaType="arraylist">
        collection>

如果不以别名的方式传递 直接报错 {carPortIds=car_port_ids}

2.子查询 carPortIds 不能是car_port_ids 这样直接报错了

<select id="selectCarportList" resultMap="BaseResultMapCarport">
        select cp.* from sys_carport cp
        <where>
          <if test="1">
              and cp.id in
              <foreach item="ed" index="index" collection="carPortIds.split(',')" open="(" separator="," close=")">
                  '${ed}'
              foreach>
          if>
        where>
    select>

3.解决了 需要把多个下划线字段屏蔽一下 不然会莫名的错误

你可能感兴趣的:(mybatis,java,开发语言)