在MyBatis-Plus 的 XML 文件中,可以使用 OGNL 表达式来判断输入的 list 是否为空。具体方法如下: SELECT * FROM user WHEREidIN <foreach collection="list"item="id"open="("close=")"separator=",">#{id}</foreach> <iftest="list != null and list.size() > 0"> AND status = 1 </if> ...
解决方法二:封装成map 先将list装进map里,在dao层用@Param取个名字。取出来就用param的名字点map里key名。 例如,map里key名是k1,@Param的名字是p1,在xml里 p1.k1 repository层: public List<AcctInfo> selectAcct(List<String> acctNos){ //把参数手动封装在Map中 Map<String, Object> map = new HashMa...
<resultMap id="StTruckInfoWithAreaPageResult" type="StTruckInfo" extends="StTruckInfoResult"> <collection property="saAreaTruckList" ofType="cn.hnmit.web.saArea.domain.SaAreaTruck" select="cn.hnmit.web.saArea.mapper.SaAreaTruckMapper.selectSaAreaTruckList" column="{truckId=id}" /> </res...
结果集Page用 PageHelper或MybatisPlus的,看自己需求。 @Override public Page<ReceivableVo> getReceivablePage(Page page, ReceivableVo receivableVo) { log.debug("应收列表查询,ReceivableVo:{},Page:{}", receivableVo, page); PageHelper.startPage((int)page.getCurrent(), (int)page.getSize()); List<R...
mybatis-plus多表查询,需自己写xml进行查询。 在mapper中定义,如需分页查询可添加page。 List<ViewJobsListVO>list(Pagepage,@Param("query")ViewJobsviewJobs); 在xml中编写sql语句,这里进行简单的自连接查询 select a.*,b.job_name as job_parent_name from view_jobs a left join view_jobs b on a...
mybatis-plus作为mybatis的增强工具,它的出现极大的简化了开发中的数据库操作,但是长久以来,它的联表查询能力一直被大家所诟病。一旦遇到left join或right join的左右连接,你还是得老老实实的打开xml文件,手写上一大段的sql语句。直到前几天,偶然碰到了这么一款叫做mybatis-plus-join的工具(后面就简称mpj了)...
一、配置xml路径 mybatis-plus: mapper-locations: classpath:mapper/*.xml 二、编写Mapper里面的方法 public interface UserMapper extends BaseMapper{ ListfindAll(); List<User>selectByXml(@Param("name")String name); } 三、编写sql select * from user <where> <iftest="name != null and name...
mybatis plus MyBatis-Plus(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 以前我们使用mybatis的时候,我们会使用MyBatis Generator优先生成单表的增删改查操作,但当修改字段删除字段的时候,是个痛苦的事情,要修改xml的很多地方。
moduleName("mybatisplus") // 设置父包模块名 .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "D://mybatis_plus")); // 设置mapperXml生成路径 }) .strategyConfig(builder -> { builder.addInclude("t_user") // 设置需要生成的表名 .addTablePrefix("t_", "c_"); // 设置过滤表前缀 ...