In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces what the common methods of MybatisPlus QueryWrapper have related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have some gains after reading this article on common methods of MybatisPlus QueryWrapper, let's take a look at it.
Common methods of QueryWrapper
MybatisPlus uses QueryWrapper test cases I, ge, gt, le, lt, isNull, isNotNull@Testpublic void testQuery () {QueryWrapper queryWrapper = new QueryWrapper (); queryWrapper .isNull ("name") .ge ("age", 12) .isNotNull ("email"); int result = userMapper.delete (queryWrapper); System.out.println ("delete return count =" + result) } II. Eq, ne@Testpublic void testSelectOne () {QueryWrapper queryWrapper = new QueryWrapper (); queryWrapper.eq ("name", "Tom"); Useruser = userMapper.selectOne (queryWrapper); / / only one record can be returned, and an exception System.out.println (user) will be thrown;} III, between, notBetween@Testpublic void testSelectCount () {QueryWrapper queryWrapper = new QueryWrapper (); queryWrapper.between ("age", 20,30) Integer count = userMapper.selectCount (queryWrapper); / / return data quantity System.out.println (count);} IV, like, notLike, likeLeft, likeRight@Testpublic void testSelectMaps () {QueryWrapper queryWrapper = new QueryWrapper (); queryWrapper .select ("name", "age") .like ("name", "e") .like right ("email", "5"); List maps = userMapper.selectMaps (queryWrapper) / / the return value is Map list maps.forEach (System.out::println);} V, orderBy, orderByDesc, orderByAsc@Testpublic void testSelectListOrderBy () {QueryWrapper queryWrapper = new QueryWrapper (); queryWrapper.orderByDesc ("age", "id"); Listusers = userMapper.selectList (queryWrapper); users.forEach (System.out::println);} VI. Insert insert@Testpublic void save () {User user = new User (); user.setAge (23) User.setEmail ("test"); user.setName ("test"); / / 1. Add userService.save (user) using service; / / 2. Add userMapper.insert (user) using mapper; 7. Delete remove@Testpublic void delete () {/ / delete userService.remove (Wrappers.query (). Lambda (). Eq (User::getAge, 3));} 8. Modify update@Testpublic void update () {User user = new User (); user.setAge (23); user.setEmail ("344"); user.setName ("test333"); UpdateWrapper updateWrapper = new UpdateWrapper () UpdateWrapper.eq ("id", "1"); / / 1.user encapsulates the modified attribute value, and updateWrapper encapsulates the modified conditional parameter value userService.update (user,updateWrapper); / / 2. Modify the corresponding parameter attribute value userService.update (Wrappers.update (). Lambda (). Set (User::getName, "2") .eq (User::getAge, 23)) according to the condition; / / 3. Determine whether the parameter is empty, and modify String name = "name"; userService.update (Wrappers.update (). Lambda (). Set (StringUtils.isNotBlank (name), User::getName, name) .eq (User::getAge, 23);} this is the end of the article on "what are the common methods of MybatisPlus QueryWrapper". Thank you for reading! I believe you all have a certain understanding of "what are the common methods of MybatisPlus QueryWrapper". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.