当前位置: 首页 > news >正文

加强网站及微信平台建设网站怎么上传到空间

加强网站及微信平台建设,网站怎么上传到空间,网站被墙 怎么做301,微信公众号运营教程转载自 mybatis多个参数(不使用param注解情况下)#xff0c;sql参数占位符正确写法 useActualParamName配置 useActualParamName允许使用方法签名中的名称作为语句参数名称。 为了使用该特性#xff0c;你的工程必须采用Java 8编译#xff0c;并且加上-parameters选项。param注解情况下)sql参数占位符正确写法 useActualParamName配置 useActualParamName允许使用方法签名中的名称作为语句参数名称。 为了使用该特性你的工程必须采用Java 8编译并且加上-parameters选项。从3.4.1开始true | falsetrue mybatis的全局配置useActualParamName决定了mapper中参数的写法默认为true 代码展示 Test public void findUserById() {SqlSession sqlSession getSessionFactory().openSession();UserDao userMapper sqlSession.getMapper(UserDao.class);User user userMapper.findUserById(1,lpf);Assert.assertNotNull(没找到数据, user); } public interface UserDao {User findUserById (int id,String name); } 1.如果useActualParamName设置为true时 传递参数需要使用 #{arg0}-#{argn}或者#{param1}-#{paramn} 比如: select idfindUserById resultTypecom.lpf.entity.User select * from m_user where id #{arg0} and name #{arg1} /select 或者 select idfindUserById resultTypecom.lpf.entity.User select * from m_user where id #{param1} and name #{param2} /select 2.如果useActualParamName设置为false时 传递参数需要使用 #{0}-#{n}或者#{param1}-#{paramn} select idfindUserById resultTypecom.lpf.entity.User select * from m_user where id #{0} and name #{1} /select 或者 select idfindUserById resultTypecom.lpf.entity.User select * from m_user where id #{param1} and name #{param2} /select 下面是多个参数的错误写法直接写参数名如果方法只有一个参数是可以用参数名代替的其实如果只有一个参数任何名称都是可以的 select idfindUserById resultTypecom.lpf.entity.User select * from m_user where id #{id} and name #{name} /select 源码解读3.4.6 在mapper的代理对象调用方法时最终会是MapperMethod对象的execute方法。如下 Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {try {// 如果目标方法是Object类继承来的直接调用目标方法if (Object.class.equals(method.getDeclaringClass())) {return method.invoke(this, args);} else if (isDefaultMethod(method)) {return invokeDefaultMethod(proxy, method, args);}} catch (Throwable t) {throw ExceptionUtil.unwrapThrowable(t);}// 从缓存中获取MapperMethod 对象,如果没有就创建新的并添加final MapperMethod mapperMethod cachedMapperMethod(method);// 执行sql 语句return mapperMethod.execute(sqlSession, args); } MapperMethod的一个内部类MethodSignature封装了Mapper接口中定义的方法的相关信息。而MethodSignature的一个属性ParamNameResolver对象处理接口中定义的方法的参数列表。 ParamNameResolver 的属性 // 记录参数在参数列表中的位置索引与参数名称之间的对应关系 private final SortedMapInteger, String names;// 记录对应的方法参数是否使用了Param注解 private boolean hasParamAnnotation; ParamNameResolver的构造函数 /*** 通过反射读取方法中的信息并初始化上面两个字段* param config* param method*/ public ParamNameResolver(Configuration config, Method method) {// 获取参数列表中每个参数的类型final Class?[] paramTypes method.getParameterTypes();// 获取参数列表上的注解 Paramfinal Annotation[][] paramAnnotations method.getParameterAnnotations();// 该集合用于记录参数索引与参数名称的对应关系final SortedMapInteger, String map new TreeMapInteger, String();int paramCount paramAnnotations.length;// 遍历所有参数for (int paramIndex 0; paramIndex paramCount; paramIndex) {if (isSpecialParameter(paramTypes[paramIndex])) {// 如果参数是RowBounds类型或者ResultHandler类型则跳过该参数continue;}String name null;// 遍历该参数上的注解集合for (Annotation annotation : paramAnnotations[paramIndex]) {if (annotation instanceof Param) {// 获取Param注解指定的参数名称hasParamAnnotation true;name ((Param) annotation).value();break;}}// 没有Param注解的话 执行下面逻辑if (name null) {// useActualParamNametrue时 即name arg0 ...if (config.isUseActualParamName()) {name getActualParamName(method, paramIndex);}if (name null) {//useActualParamName false是 即 name0 ...// use the parameter index as the name (0, 1, ...)// 使用参数的索引作为其名称name String.valueOf(map.size());}}map.put(paramIndex, name);}names Collections.unmodifiableSortedMap(map); } names集合主要是在ParamNameResolver.getNamedParams方法中使用 /**** param args 用户传入的参数值列表* return*/ public Object getNamedParams(Object[] args) {final int paramCount names.size();if (args null || paramCount 0) {return null;} else if (!hasParamAnnotation paramCount 1) {// 未使用Param注解且参数列表只有一个return args[names.firstKey()];//即args[0] 参数的值} else {// 下面是为参数创建param索引的格式作为默认参数名称 如param1 下标从1开始final MapString, Object param new ParamMapObject();int i 0;for (Map.EntryInteger, String entry : names.entrySet()) {param.put(entry.getValue(), args[entry.getKey()]);// add generic param names (param1, param2, ...)final String genericParamName GENERIC_NAME_PREFIX String.valueOf(i 1);// ensure not to overwrite parameter named with Paramif (!names.containsValue(genericParamName)) {param.put(genericParamName, args[entry.getKey()]);}i;}return param;} } 总结 1.如果接口方法有一个或多个参数并且使用了Param注解sql语句中的参数用注解的value值 2.如果接口方法的参数只有一个并且没有使用Parma注解sql语句直接使用任何名称均可。 3.如果接口的方法有多个参数并且没有使用Parma注解sql语句使用param1...paramn是不会错的。 4.sql语句中的参数占位符名称和接口方法的参数名称没有什么关系。
http://www.pierceye.com/news/948022/

相关文章:

  • 便宜网站建设模板网站网站做推广需要营业执照
  • 网站地址栏图标文字企业网站设计公司
  • 公司做网站推广有没有用网址导航被更改了怎么换回来
  • 好看云在线网站模板下载 迅雷下载 迅雷下载地址免费建小程序网站
  • 通州网站制作游戏网站域名
  • 医疗网站前置审批要多长时间营销型外贸网站广州
  • 哈尔滨网站建设oeminc购买手表网站
  • 营销推广公司兰州seo培训
  • 南城网站建设公司php购物网站开发实例源码
  • 无锡网站备案百度应用市场
  • 高端房产网站建设上传空间网站
  • 上海城建建设官方网站中企动力网站价格
  • 网站建设中国十强阜阳网站制作公司多少钱
  • 网站建设公司 温州虚拟机电脑网页版
  • 网站建设原理与实践深建市住房和城乡建设局网站
  • 南通建设招聘信息网站平面设计工作室怎么接单
  • 手机网站开发技巧wordpress网站外包
  • 南昌外贸网站建设宿州做企业网站
  • 专题网站建站给医院做网站赚钱吗
  • 泉州市做网站网站建设培训需要多少钱
  • 网站开发的外文翻译静态网站制作视频
  • 小企业做网站有用吗大气网站首页欣赏
  • 常见的企业网站有哪些苏州网站建设一站通
  • 陕西省高速公路建设集团公司网站外包网站开发 收费
  • 免费做网站刮刮卡腾讯html网页制作软件
  • 网站快照网站反链一般怎么做
  • 山东东营建设网官方网站专做h5的公司网站
  • 电商网站建设题库做海岛旅游类网站的背景及意义
  • 网站开发后台框架wordpress 文章同步微信
  • 小型网站有哪些怎么搭建自己的网站