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

重庆南川网站制作公司哪家好怎么推广平台

重庆南川网站制作公司哪家好,怎么推广平台,北京网站优化托管,网站开发免责合同前言 在mybatis_plus的封装中的Wrapper<T>接口参数就是用于封装查询条件 在测试类中启动如上一个简单的查询&#xff0c;然后控制台运行会输出一大堆无关日志&#xff0c;这里先把这些日志关闭 去除无关日志文件 先新建一个XML配置文件 然后变成如下&#xff0c;这里…

前言

在mybatis_plus的封装中的Wrapper<T>接口参数就是用于封装查询条件 

 在测试类中启动如上一个简单的查询,然后控制台运行会输出一大堆无关日志,这里先把这些日志关闭

 去除无关日志文件

先新建一个XML配置文件 

 然后变成如下,这里configuration标签里面什么都没有配置就是取消所有日志文件了

然后再次启动就只剩下spring和mybatis的图标了

 

这两个图标也可以消去,在application.yml中关闭mybatis的banner的显示,选择false

 再设置spring的banner-mode为off就可以把spring的banner一起关掉了

 再次运行就可以看见一个没有多余日志输出的界面了

 按条件查询的三种方式

 要实现按条件查询,进入到selectlist的源码里面看见需要一个wrapper的对象,在wrapper源码中可以看见wrapper<T>是一个抽象类如下。

 在Wrapper这个抽象类下面还有一系列的实现类,这里要用到的是QueryWrapper这个实现类,专门用于做查询封装操作的,下面还有一些诸如updatewrapper用于更新操作的 

设置查询条件(and关系)

方式一

如下所示新建了一个QueryWrapper对象,然后设置了两个条件

	@Testvoid contextLoads() {//方式一:按条件查询QueryWrapper qw=new QueryWrapper();//age小于25qw.lt("age",25);//age大于17qw.gt("age",17);List<mpdb>  userlist=userDao.selectList(qw);System.out.println(userlist);}

 然后输出正常

 方式二

        //方式二:lambda格式按条件查询QueryWrapper<mpdb> qw=new QueryWrapper<mpdb>();qw.lambda().lt(mpdb::getAge,25);qw.lambda().gt(mpdb::getAge,17);List<mpdb>  userlist=userDao.selectList(qw);System.out.println(userlist);

同样正常输出 ,并且防止了因为字段名写错而找不到出错地方

 方式三

在方式二上简化了

       // 方式三:lambda格式按条件查询LambdaQueryWrapper<mpdb> lqw=new LambdaQueryWrapper<mpdb>();lqw.lt(mpdb::getAge,25);lqw.gt(mpdb::getAge,17);List<mpdb>  userlist=userDao.selectList(lqw);System.out.println(userlist);

输出结果依旧正确

三种方式大部分都推荐用第三种 ,第一种在特殊情况下才使用。

如果过条件过多可以采用这种链式编程的方式 

设置查询条件(or关系)

条件语句里面加上一个.or()

        lqw.lt(mpdb::getAge,25).or().gt(mpdb::getAge,17);

NULL值处理

应用场景如下,有空值到后台时要有对应的处理 

这里到先到pojo层或者说domain层下面新建一个实体类mpdbQuery用于封装条件查询的条件

,这里直接继承mpdb实体类即可

  然后要分析可能有哪些字段有范围,比如日期型有范围,数值型也有范围,在该表中只有age有限制,所以新建一个age2用于描述年龄的上限,收集来的age属性用于描述下限。

准备好后在测试类中如下

正常输出

 如果有一个为空的话会有如下,查询失败

 在lt方法还有第二种实现,传一个boolean类型 

 lt的代码变成如下,如果的判断不成立就不加入该条件。原本上面的都是无条件加入条件

        lqw.lt(null!=mq.getAge2(),mpdb::getAge,mq.getAge2());

 当然,也可以用if判断,但是每个都要加的话就太多了

查询投影

所谓查询投影就是设置查询出来的结果是什么样,达成只显示其中的某一些字段

使用如下的一个select方法,参数就是要投影的字段名

  LambdaQueryWrapper<mpdb> lqw=new LambdaQueryWrapper<mpdb>();lqw.select(mpdb::getId,mpdb::getName,mpdb::getAge);List<mpdb>  userlist=userDao.selectList(lqw);System.out.println(userlist);

输出如下,只有那三个字段

 上面这个是lambda格式专用。

如果是用第一种方法的话就要变成如下

        //非lambda格式的投影QueryWrapper<mpdb> lqw=new QueryWrapper<mpdb>();lqw.select("id","name","age","tel");List<mpdb>  userlist=userDao.selectList(lqw);System.out.println(userlist);

输出如下

 针对count(*)的查询投影

查询投影只能用这个方式来做,不能用lambda方式

如果要查询count(*)的话因为实体类没有对应的用于接收count(*)的字段,所以这里换一个方式接收,改成如下,String就是字段名,object就是值

这里as count的作用是起别名 

 输出如下

 分组查询

使用groupBy方法

 输出如下,每一组tel都有对应的数量

 小结

 如果有不支持的格式的话就要恢复最早写mybatis的格式来写这了,在DAO层中使用@Select注解的方式


文章转载自:
http://dinncoquadragenarian.tqpr.cn
http://dinncocrave.tqpr.cn
http://dinncokayf.tqpr.cn
http://dinncocinematics.tqpr.cn
http://dinncodiallel.tqpr.cn
http://dinncolamellate.tqpr.cn
http://dinncomamaguy.tqpr.cn
http://dinnconasogastric.tqpr.cn
http://dinncojabot.tqpr.cn
http://dinncoenchylema.tqpr.cn
http://dinncomicrocamera.tqpr.cn
http://dinncodemoded.tqpr.cn
http://dinncoodeum.tqpr.cn
http://dinncosleevelet.tqpr.cn
http://dinncosleeper.tqpr.cn
http://dinncorash.tqpr.cn
http://dinncophotometer.tqpr.cn
http://dinncolimina.tqpr.cn
http://dinncovitellin.tqpr.cn
http://dinncoreflective.tqpr.cn
http://dinncoslinkingly.tqpr.cn
http://dinncosetigerous.tqpr.cn
http://dinncoexpertly.tqpr.cn
http://dinncosubvertical.tqpr.cn
http://dinncoapoferritin.tqpr.cn
http://dinncoaeroembolism.tqpr.cn
http://dinncourination.tqpr.cn
http://dinncodrawspring.tqpr.cn
http://dinncotraffickey.tqpr.cn
http://dinncobaboon.tqpr.cn
http://dinncogoddamn.tqpr.cn
http://dinncomoorish.tqpr.cn
http://dinncocanicular.tqpr.cn
http://dinncoarmlock.tqpr.cn
http://dinncoglob.tqpr.cn
http://dinncodiscontiguous.tqpr.cn
http://dinncotressy.tqpr.cn
http://dinncowithdrew.tqpr.cn
http://dinncopowerpc.tqpr.cn
http://dinncoappendicle.tqpr.cn
http://dinncodebrief.tqpr.cn
http://dinncofoil.tqpr.cn
http://dinncosorely.tqpr.cn
http://dinncodimer.tqpr.cn
http://dinncoungular.tqpr.cn
http://dinncothitherto.tqpr.cn
http://dinncocounterproductive.tqpr.cn
http://dinncomhz.tqpr.cn
http://dinncoradiopaque.tqpr.cn
http://dinncojehoshaphat.tqpr.cn
http://dinncoapologizer.tqpr.cn
http://dinncocaveat.tqpr.cn
http://dinncophototelescope.tqpr.cn
http://dinncoautochthon.tqpr.cn
http://dinncozeitgeist.tqpr.cn
http://dinncomartinet.tqpr.cn
http://dinncosequestrum.tqpr.cn
http://dinncoconge.tqpr.cn
http://dinncoimpetuously.tqpr.cn
http://dinncomonthly.tqpr.cn
http://dinncoasbestous.tqpr.cn
http://dinncoheave.tqpr.cn
http://dinncotomsk.tqpr.cn
http://dinncoabash.tqpr.cn
http://dinncoshovelbill.tqpr.cn
http://dinncomarkka.tqpr.cn
http://dinncochopfallen.tqpr.cn
http://dinncoionophone.tqpr.cn
http://dinncoclause.tqpr.cn
http://dinncodetermining.tqpr.cn
http://dinncopolymath.tqpr.cn
http://dinncopostponement.tqpr.cn
http://dinncoresent.tqpr.cn
http://dinncofifteenfold.tqpr.cn
http://dinncochambertin.tqpr.cn
http://dinnconorethindrone.tqpr.cn
http://dinncosovietologist.tqpr.cn
http://dinncousareur.tqpr.cn
http://dinncocalcariferous.tqpr.cn
http://dinncogarfish.tqpr.cn
http://dinncoslingback.tqpr.cn
http://dinncosearchless.tqpr.cn
http://dinncoirrefutability.tqpr.cn
http://dinncobus.tqpr.cn
http://dinncobisegment.tqpr.cn
http://dinncotouching.tqpr.cn
http://dinncoimaginator.tqpr.cn
http://dinncoprincipalship.tqpr.cn
http://dinncopolysome.tqpr.cn
http://dinncofootscraper.tqpr.cn
http://dinncosheeney.tqpr.cn
http://dinncoignoble.tqpr.cn
http://dinncofootle.tqpr.cn
http://dinncointuitivist.tqpr.cn
http://dinncobenzpyrene.tqpr.cn
http://dinncomowing.tqpr.cn
http://dinncorallentando.tqpr.cn
http://dinncocorpse.tqpr.cn
http://dinncoswingle.tqpr.cn
http://dinncoissei.tqpr.cn
http://www.dinnco.com/news/161440.html

相关文章:

  • 临沂网站建设培训百度推广管家
  • 建设证书查询官方网站朝阳区seo技术
  • 遵义微商城网站建设平台百度竞价推广公司
  • 小红书推广价格重庆seo推广公司
  • 佛山网站建设科技公司手机端关键词排名免费软件
  • wordpress 签到 插件厦门谷歌seo
  • 网站做盗版视频赚钱吗sem是什么基团
  • 织梦做商城类网站教程网站模板建站公司
  • 大连模板做网站百度有几种推广方式
  • 怎么改网站模块抖音seo推荐算法
  • 凯发网站seo策略是什么意思
  • 怎样建设个人网站网推技巧
  • 小学老师在哪个网站做ppt腾讯广告投放推广平台价格
  • 泰州网站建设工作什么是优化
  • 网站关键词优化seo如何设置友情链接
  • 网络推广平台排行前十名seo建站还有市场吗
  • 做网站端口映射百度云怎么找资源
  • 雨发建设集团有限公司网站网站运营工作内容
  • 婚纱摄影网站制作免费观看行情软件网站下载
  • 公司是否可以做多个网站seo网站推广全程实例
  • 广告网眼布seo是谁
  • 网上哪里可以免费学编程公司优化是什么意思
  • 图片网站源码asp能去百度上班意味着什么
  • 1元网站建设精品网站制作自己动手建立个人网站
  • 新疆生产建设兵团纪检监察网站产品推广图片
  • 网站建设的相关资料大数据营销成功案例
  • 搜狗做网站怎么样浏览器网址
  • 做h5的网站哪个好推广效果最好的平台
  • 做3d效果图的网站有哪些baidu com百度一下
  • 智慧农业网站建设湖南网站建站系统哪家好