publicclassSampleTest{@AutowiredprivateUserMapperuserMapper;@TestpublicvoidtestSelect(){MPJLambdaWrapper<User>wrapper=JoinWrappers.lambda(User.class).selectCollection(AddressDO.class,UserDTO::getAddressList).leftJoin(Address.class,Address::getUserId,User::getId);List<UserDTO>list=userMapper.selectJoinList...
三、pom依赖和配置文件 最近发现一个好玩的框架,我们知道mybatis-plus在连表查询上是不行的,如果需要连表查询,那么我们就得乖乖的去写xml文件了,但是今天发现一个新的框架 mybatis-plus-join。它既包含了mybatis-plus的所有优点,然后还支持连表查询,还支持对多,对一的查询,行了废话不多说直接看代码吧。 一、...
一对一,一对多使用:https://ylctmh.com/pages/core/lambda/select/selectCollection.html 简单的SQL函数使用:https://ylctmh.com/pages/core/lambda/select/selectFunc.html ON语句多条件支持:https://ylctmh.com/pages/core/lambda/join/leftJoin.html 分页查询 mpj中也能很好的支持列表查询中的分页功能,首先我们...
publicclassSampleTest{@AutowiredprivateUserMapperuserMapper;@TestpublicvoidtestSelect(){MPJLambdaWrapper<User>wrapper=JoinWrappers.lambda(User.class).selectCollection(AddressDO.class,UserDTO::getAddressList).leftJoin(Address.class,Address::getUserId,User::getId);List<UserDTO>list=userMapper.selectJoinList...
classtest{@ResourceprivateUserMapperuserMapper;@TestvoidtestResultMap(){MPJLambdaWrapper<UserDO>wrapper=newMPJLambdaWrapper<UserDO>().selectAll(UserDO.class)//对多查询.selectCollection(AddressDO.class,UesrDTO::getAddressList)//对一查询.selectAssociation(AddressDO.class,UesrDTO::getAddress).leftJoin(Ad...
class test { @Resource private UserMapper userMapper; @Test void testResultMap() { MPJLambdaWrapper<UserDO> wrapper = new MPJLambdaWrapper<UserDO>() .selectAll(UserDO.class) //一对多查询 .selectCollection(AddressDO.class, UesrDTO::getAddressList) .leftJoin(AddressDO.class, AddressDO::getUser...
一对一,一对多使用:https://ylctmh.com/pages/core/lambda/select/selectCollection.html 简单的SQL函数使用:https://ylctmh.com/pages/core/lambda/select/selectFunc.html ON语句多条件支持:https://ylctmh.com/pages/core/lambda/join/leftJoin.html
Mybatis-Plus-Join不仅支持基础功能,还扩展了分页查询功能,能根据不同的数据库自动拼接分页方言。在一对多和一对一查询上,也非常便捷,只需要调用相应的函数,如selectCollection和selectAssociation,映射类型和别名设置也十分灵活。总结来说,Mybatis-Plus-Join是无侵入的,无缝融入现有工程,使用起来与MP...
selectCollection(AddressDO.class, UesrDTO::getAddressList) //对一查询 .selectAssociation(AddressDO.class, UesrDTO::getAddress) .leftJoin(AddressDO.class, AddressDO::getUserId, UserDO::getId); List<UserDTO> dtoList = userMapper.selectJoinList(UserDTO.class, wrapper); //关于对多分页查询 //...
2.使用selectAssociation MPJLambdaWrapper<User> lqw = new MPJLambdaWrapper<>(); lqw.selectAll(User.class);//正常 lqw.selectAs(User::getUserName, UserDTO::getNicknameA);//正常 lqw.selectAs("t.user_name", UserDTO::getNicknameB);//sql正常但实体类中nicknameB值为null ...