22. Mybatis 和 實體類的一個錯誤:Cause: java.lang.IllegalArgumentException: argument type mismatch] with root cause
阿新 • • 發佈:2022-03-08
-
錯誤展示:
-
實體類:
public class DeviceTypeImg { private LDeviceType deviceType; private LImg icon; public DeviceTypeImg(LDeviceType deviceType, LImg icon) { this.deviceType = deviceType; this.icon = icon; } public LDeviceType getDeviceType() { return deviceType; } public void setDeviceType(LDeviceType deviceType) { this.deviceType = deviceType; } public LImg getIcon() { return icon; } public void setIcon(LImg icon) { this.icon = icon; } }
- MyBatis xml:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.tjl.health.admin.dao.LDeviceTypeMapperCustom"> <resultMap id="BaseResultMap" type="com.tjl.health.admin.pojo.vo.DeviceTypeImg"> <association property="deviceType" javaType="com.tjl.health.model.LDeviceType"> <id column="id" jdbcType="VARCHAR" property="id" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="icon_id" jdbcType="VARCHAR" property="iconId" /> <result column="description" jdbcType="VARCHAR" property="description" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="delete_time" jdbcType="TIMESTAMP" property="deleteTime" /> <result column="parent_id" jdbcType="VARCHAR" property="parentId" /> </association> <association property="icon" javaType="com.tjl.health.model.LImg"> <result column="imgId" jdbcType="VARCHAR" property="id" /> <result column="imgUrl" jdbcType="VARCHAR" property="url" /> </association> </resultMap> <select id="selectById" resultMap="BaseResultMap" > select ldt.id, ldt.`name`, ldt.icon_id, ldt.description, ldt.create_time, ldt.update_time, ldt.delete_time, ldt.parent_id, li.id imgId, li.url imgUrl from l_device_type ldt left join l_img li on ldt.icon_id=li.id where ldt.id=#{deviceTypeId} </select> </mapper>
- 解決方式
把實體類的建構函式去掉