Mybaits注解方式 There is no getter for property named 'name' in 'class java.lang.String'

接口层的代码:

@Select("select cid,rl.companyName `name`,(select IFNULL(companyLogo,'') from company cp where cp.cid = rl.cid) as companyLogo,merRealStatus "
			+ "from RealNameAuditingFromJDJR rl where 1=1 "
			+ "<if test='name != null and name != \"\" '>"
			+ "and rl.companyName like '${name}'  "
			+ "</if>"
			+ "order by createTime desc")
	@Options(statementType=StatementType.CALLABLE)
	List<Map<String, Object>> getAllCompanyList(String name);


解决办法:

加一个@Param("name")就好了:

@Select("select cid,rl.companyName `name`,(select IFNULL(companyLogo,'') from company cp where cp.cid = rl.cid) as companyLogo,merRealStatus "
			+ "from RealNameAuditingFromJDJR rl where 1=1 "
			+ "<if test='name != null and name != \"\" '>"
			+ "and rl.companyName like '${name}'  "
			+ "</if>"
			+ "order by createTime desc")
	@Options(statementType=StatementType.CALLABLE)
	List<Map<String, Object>> getAllCompanyList(@Param("name")String name);



关于参数是否参与过滤的写法:

1、if test中的参数名称不需要加${};

2、${}和#{}的区别

      #{}是占位符,比${}更安全

      如果是in查询,一定需要用${},注意构造参数的格式如单引号

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 程序猿惹谁了 设计师:白松林 返回首页