nested exception is org.apache.ibatis.binding.BindingException: Parameter 'goodsId' not found. Avail
来源:互联网 发布:mac底部菜单隐藏了 编辑:程序博客网 时间:2024/06/08 13:46
nested exception is org.apache.ibatis.binding.BindingException: Parameter 'goodsId' not found. Available parameters are [companyId, id, param1, param2]
这是控制台报错原因,即使下班了.我也要写好再回去.坑了一天了.
话不多说,贴代码
syscore.confirm("提示", "确认要删除选中的入库信息吗?", function (flag) { if (flag) { $.post("${ctxPath}/inventory/store/delete.html", {id: row.id}, function (rsData) { if (rsData.message.code != "0") { syscore.alert('错误', rsData.message.mess, 'error'); return; } $(".easyui-datagrid").datagrid("reload"); }, "json") } })
@RequestMapping("delete") @ResponseBody public Map<String,Object> delete(Long id) throws ServiceException { entryStockService.deleteByKey(null,id); return SysStaticParam.resultMessage("删除入库信息成功!"); }
接下来就是service和impl一样,没问题
mapper.java
/** * 删除记录 * * @param companyId,企业号 * @param id,主键 * @return */ public int deleteByKey(@Param("companyId") String companyId, @Param("id") Long id);
mapper.xml
<delete id="deleteByKey">delete from i_entry_stock where 1=1 <if test="goodsId != null" > and id =#{id} </if> <if test="categoryId != null" > and COMPANY_ID=#{companyId} </if></delete>
谁都不服,就服老太太....
<delete id="deleteByKey">delete from i_entry_stock where 1=1 <if test="id != null" > and id =#{id} </if> <if test="companyId != null" > and COMPANY_ID=#{companyId} </if></delete>
看了网上的几个说明,有几个注意点就是:
1.使用一个参数时,mapper中可以不使用@Param.但是多个参数时,就必须使用: mapper.java中已经使用;
2,mapper.xml文件中
test="categoryId != null" > and COMPANY_ID=#{companyId}
与数据库和pojo中,属性名称不对应.报错...即sql字段名称没有对应上.
总结一下,就看到两条.尤其是喜欢复制代码的人,请注意了.
阅读全文