mybatis出错

xml文件:

 <update id="decreaseStock">
update item_stock
set
stock = stock - #{amount,jdbcType=INTEGER}
where item_id = #{itemId,jdbcType=INTEGER} and stock >= #{amount,jdbcType=INTEGER}
</update>

DAO接口:

 int decreaseStock(@Param("itemId")Integer itemId, @Param("amont")Integer amount);

问题出现在没见标红的注解。

思考:为什么有的有的方法不用加 @Param 注解?举例:int updateByPrimaryKeySelective(ItemStockDO record);

1、不使用@Param注解时,参数只能有一个,当参数超过两个时,要用@Param

转:

实例一 @Param注解单一属性

dao层示例

Public User selectUser(@param(“userName”) String name,@param(“userpassword”) String password);

xml映射对应示例

<select id=" selectUser" resultMap="BaseResultMap">
select * from user_user_t where user_name = #{userName,jdbcType=VARCHAR} and user_password=#{userPassword,jdbcType=VARCHAR}
</select>

注意:采用#{}的方式把@Param注解括号内的参数进行引用(括号内参数对应的是形参如 userName对应的是name);

实例二 @Param注解JavaBean对象

dao层示例

public List<user> getUserInformation(@Param("user") User user);

xml映射对应示例

<select id="getUserInformation" parameterType="com.github.demo.vo.User" resultMap="userMapper">
select
<include refid="User_Base_Column_List" />
from mo_user t where =
<!-- 因为传进来的是对象所以这样写是取不到值得 -->
<if test="user.userName!=null and user.userName!=''"> and t.user_name = #{user.userName} </if>
<if test="user.userAge!=null and user.userAge!=''"> and t.user_age = #{user.userAge} </if>
</select>

nested exception is org.apache.ibatis.binding.BindingException的更多相关文章

  1. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'username' not found. Available parameters are [1, 0, param1, param2]

    Spring+mybatis错误:org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.bi ...

  2. 怪事年年有,今天特别多!org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'empno' not found. Available parameters are [emp, deptno, param1, param

    错误: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Binding ...

  3. MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.

    在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...

  4. Springboot-001-解决nested exception is org.apache.ibatis.binding.BindingException: Parameter 'env' not found. Available parameters are [arg1, arg0, param1, param2]

    环境:Springboot + Mybatis + MySQL + VUE 场景: 前端发出数据比对请求,在服务后台与数据库交互时,接口提示错误信息如下所示: { "code": ...

  5. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b

    Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid b ...

  6. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [arg1, arg0, param1, param2]

    2018-06-27 16:43:45.552  INFO 16932 --- [nio-8081-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : ...

  7. spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    spring boot集成mybatis-plus插件进行自定义sql方法开发时报nested exception is org.apache.ibatis.binding.BindingExcept ...

  8. HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException

    在使用Maven工程管理工具整合SSM框架时,Mybatis使用逆向工程生成的pojo,mapper接口及映射文件,把mapper接口和映射文件放在DAO工程的同一级src/main/java目录下. ...

  9. Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement

    原因: 此异常的原因是由于mapper接口编译后在同一个目录下没有找到mapper映射文件而出现的.由于maven工程在默认情况下src/main/java目录下的mapper文件是不发布到targe ...

  10. HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    今天整合ssm框架 时 遇到的问题 困扰我好长时间     原因就是  mapper文件 没有被加载进来 但是 为什么没有被加载进来呢  因为中间的配置文件出了一些问题 网上大多数说法是   在pom ...

随机推荐

  1. 安装win10提示“我们无法创建新的分区,也找不到现有分区”

    用U盘安装操作系统,但是遇到了这种问题. 出现这种情况可能是硬盘格式通过指令写死了,所以我们需要通过指令把格式清零, 补充: 其实系统找不到系统分区这种情况其实就是引导程序出了问题,可以用大白菜这种w ...

  2. Node.js express模块 http服务

    var express = require('express'); var app = express(); app.get('/', function(req, res){ res.send('he ...

  3. mysql数据库指定ip远程访问

    1.登录 mysql -u root -p 之后输入密码进行登陆 2.权限设置及说明 2.1添加远程ip访问权限 GRANT ALL PRIVILEGES ON *.* TO 'root'@'192. ...

  4. Qt编写自定义控件17-按钮进度条

    前言 按钮进度条,顾名思义,表面上长得像一个按钮,单击以后切换成进度条指示按钮单击动作执行的进度,主要用在一些需要直接在按钮执行动作显示对应进度的场景,在很多网页中经常看到这种效果,这个效果有个优点就 ...

  5. Attention机制在深度学习推荐算法中的应用(转载)

    AFM:Attentional Factorization Machines: Learning the Weight of Feature Interactions via Attention Ne ...

  6. SpringBoot: 9.整合thymeleaf(转)

    1.创建maven项目,添加项目所需依赖 <!--springboot项目依赖的父项目--> <parent> <groupId>org.springframewo ...

  7. Unreal Engine* 4/英特尔® VTune™ Amplifier 使用指南

    借助英特尔 VTune Amplifier,可以通过单一易用的分析界面获得先进的分析功能.UE4 和英特尔 VTune Amplifier 相互配合,支持调查代码并进行分析,从而在多个内核上顺畅运行. ...

  8. robots.txt文件

    网站通过一个符合Robots协议的robots.txt文件来告诉搜索引擎哪些页面可以爬取.Robots.txt协议全称“网络爬虫排除标准”.一般情况下,该文件以一行或多行User-agent记录开始, ...

  9. 【计算机视觉】OpenCV之GPU与OpenCL的相关内容说明

    1 扩展库简介OpenCV(Open Source Computer Vision Library)是一个致力于实时处理计算机视觉问题的开源库.它最初由Intel公司开发,以GPL许可协议发布,后来由 ...

  10. day20 logging模块、re模块

    今日内容: 1.logging模块 2.re模块 1.logging模块 -- 什么是logging模块 -- logging模块是用来进行记录日志的模块,主要作用是将想要输出的日志进行分级,然后以不 ...