nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'optUser' in 'class java.lang.Long'
异常类型
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘optUser’ in ‘class java.lang.Long’
说明
虽然异常提示没有optUser的getter,但在实体里已经写了getter。
实体
@Getter
@Setter
public class EndStockCheckReqParam {
/**
* 标记
*/
@ApiDocField(description = "标记 0-作废,1-结束",dataType = DataType.STRING,required = true)
@NotBlank(message = "标记不能为空")
private String flag;
/**
* 盘点单号
*/
@ApiDocField(description = "盘点单号",dataType = DataType.STRING,required = true)
@NotEmpty(message = "盘点单号不能为空")
private String stockCheckId;
/**
* 作废人
*/
@ApiDocField(description = "作废人",dataType = DataType.LONG)
private Long optUser;
}
mapper方法
public Long getOwnerType(Long optUser);
xml文件
<select id="getOwnerType" resultType="java.lang.Long">
SELECT B.OWNER_TYPE
FROM SYS_USER A, B_OWNER B
WHERE A.OWNER_ID = B.OWNER_ID
<if test="optUser != null">
AND A.USERID = #{optUser}
</if>
</select>
解决办法
- 在mapper方法中添加@param
mapper方法
public Long getOwnerType(@Param("optUser") Long optUser);
xml文件
<select id="getOwnerType" resultType="java.lang.Long">
SELECT B.OWNER_TYPE
FROM SYS_USER A, B_OWNER B
WHERE A.OWNER_ID = B.OWNER_ID
<if test="optUser != null">
AND A.USERID = #{optUser}
</if>
</select>
- 使用jdbcType,不用if判断
mapper方法
public Long getOwnerType( Long optUser);
xml文件
<select id="getOwnerType" resultType="java.lang.Long">
SELECT B.OWNER_TYPE
FROM SYS_USER A, B_OWNER B
WHERE A.OWNER_ID = B.OWNER_ID
AND A.USERID = #{optUser,jdbcType=BIGINT}
</select>