注解@Param有以下两种:

1、Spring
org.springframework.data.repository.query.Param
2、mybatis
org.apache.ibatis.annotations.Param

两者的区别在于:

spring的注解参数按照先后顺序传入,如[arg1, arg0, param1, param2]

mybatis的注解则是使用参数名传入,如{#userId}

注意

如果使用spring的注解,而xml的SQL使用参数名取值,会报下面的错:

        org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [arg1, arg0, param1, param2]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy128.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:158)
at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:76)
at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:62)
at com.sun.proxy.$Proxy187.queryEquipmentAndPositionByProjectId(Unknown Source)

使用@Param注解时注意org.springframework.data.repository.query.Param与org.apache.ibatis.annotations.Param的区别的更多相关文章

  1. import org.apache.ibatis.annotations.Param 报错

    说明缺少依赖 <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus ...

  2. Caused by: java.lang.ClassNotFoundException: org.springframework.data.repository.config.BootstrapMode

    1.起因,启动SpringBoot2.0的时候报了这个错误.说找不到类,咱也是刚学SpringBoot2.0,咱也不懂,咱也不知道问谁,研究一翻,找不到原因就百度了. 参考链接:https://blo ...

  3. org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional;

    升级springboot到2.0时,碰到了一大堆问题,上面异常原因是jar版本冲突了,有的模块忘记更新版本了,统一一下版本就可以了

  4. Mybatis中的@Param注解(自己没试过)

    @Param是MyBatis所提供的(org.apache.ibatis.annotations.Param),作为Dao层的注解,作用是用于传递参数,从而可以与SQL中的的字段名相对应//https ...

  5. org.springframework.data.mapping.PropertyReferenceException: No property created found for type

    错误原因:org.springframework.data.domain.SortSort sort=new Sort(Sort.Direction.DESC,"created_time&q ...

  6. @Param注解

    关于mybatis的@Param注解和参数 引用 https://www.cnblogs.com/whisper527/p/6568028.html 薇飘意 1,使用@Param注解 当以下面的方式进 ...

  7. 关于mybatis的@Param注解和参数

    1,使用@Param注解 当以下面的方式进行写SQL语句时: @Select("select column from table where userid = #{userid} " ...

  8. @Param注解的用法解析

    实例一 @Param注解单一属性 dao层示例 Public User selectUser(@param(“userName”) String name,@param(“userpassword”) ...

  9. Mybatis中的@Param注解

    前言 今天在使用Mybatis时遇到一个问题,主要出错原因在于Mybatis的@Param注解,如果我不在参数前面加上@Param注解,数据库操作就会报错,如下: @Param作用 @Param注解的 ...

  10. 使用@Param注解

    1,使用@Param注解 当以下面的方式进行写SQL语句时: @Select("select column from table where userid = #{userid} " ...

随机推荐

  1. 开启Runjar , 使用beeline连接hive

    要先开启hadoop服务 进入root用户hive目录 输入bin/hiveservices.sh stop          停止 输入bin/hiveservices.sh start      ...

  2. 【运维】通过gotty实现网页代理访问服务器及K8S容器操作实践

    Gotty 是Golang编写的可以方便的共享系统终端为web应用,是一个灵活强大的通过web访问终端的工具.本文将主要通过搭建Gotty实现对K8S容器的访问操作,开发如果想要正常的进行容器访问以及 ...

  3. NTP Mode 6 检测漏洞【原理扫描】

    系统: AIX7 cd /etc cp ntp.conf ntp.conf.bak vi net.conf ## 在最后加上一行 restrict default notrust nomodify n ...

  4. R语言Apriori关联规则、kmeans聚类、决策树挖掘研究京东商城网络购物用户行为数据可视化|附代码数据

    全文链接:http://tecdat.cn/?p=30360 最近我们被客户要求撰写关于网络购物用户行为的研究报告,包括一些图形和统计输出. 随着网络的迅速发展,依托于网络的购物作为一种新型的消费方式 ...

  5. BIP change数据改变前的事件

    viewModel .get("certMaterialClass_name") .on("beforeValueChange", function (data ...

  6. 全链路压测SOP

    压测模型构建:人工 线上(大促)流量数据 (数据脱敏) 日常流量数据 业务方新的特性产生的变更数据 友商做过的事情 压测模型构建:自动 流程包括:录制-清洗-回放 (目前能做好的公司非常少) 压测标准 ...

  7. koa源代码解析

    koa不愧为小而美,主要代码很少.简单来说,1,koa封装了node的http.createServer((req,res)=>{})的入参req,res到ctx同名属性(一个自定义对象)中,并 ...

  8. 摹客演示Axure原型,适配更丰富机型

    Hi!各位小伙伴!又到了摹客的新功能播报时间.本次更新,对Axure原型的演示进行了优化,支持预览不同分辨率的布局:在设计规范方面,非编辑者的界面标识也更加清晰:另外还有一些细节体验的优化.下面就一起 ...

  9. wrf-python离线安装

    由于客户环境不能联网,python的插件库只能离线安装,wrf库的安装中踩了不少坑,特此记录. 1.官方插件库pypi.org只有压缩包,没有提供wheel,在线安装没有问题. 2.下载压缩包解压后, ...

  10. 假设业务需要,在页面一屏中一次性展示大量图片(100张),导致img组件同时发起大量的请求,导致浏览器性能被消耗殆尽,页面卡死。怎么优化?

    1.所有图片先提供占位图2.懒加载思想3.使用队列的方式4.通过信号量的机制,结合队列.例如设置可用资源数为10,则保证同一时刻,只有10张图片正在请求,其它图片处于loading状态,任意图片请求完 ...