Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Length judgment and insertion method of mybatis Array and set

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "mybatis array and set length judgment and insertion method". In daily operation, I believe that many people have doubts about the length judgment and insertion method of mybatis array and set. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "mybatis array and set length judgment and insertion method". Next, please follow the editor to study!

Length judgment and insertion of mybatis arrays and collections 1. It is the collection attribute that uses foreach.

This property must be specified, but the value of the property is different in different cases

There are four main situations:

If a single parameter is passed in and the parameter type is a List, the value of the collection property is list.

If a single parameter is passed in and the parameter type is a non-list Collection, the value of the collection property is collection.

If a single parameter is passed and the parameter type is an array array, the property value of collection is array

If the dao layer specifies the name of param, or if the dao layer passes the name of param or the key of map in map,collection

DefaultSqlSessionprivate Object wrapCollection (final Object object) {if (object instanceof Collection) {StrictMap map = new StrictMap (); map.put ("collection", object); if (object instanceof List) {map.put ("list", object);} return map;} else if (object! = null & object.getClass (). IsArray ()) {StrictMap map = new StrictMap (); map.put ("array", object) Return map;} return object;} 2, judge length

Collection:

Array:

Mybatis array and set judgment non-empty and length array judgment

When the parameter object is an array Object []. First determine whether it is null, and if it is not null, then you can determine whether the array length object.length is greater than 0.

Set judgment

When the parameter object is set List, you can first determine whether it is null, and if it is not null, you can determine whether the set length object.size () is greater than 0.

At this point, the study on the length judgment and insertion method of mybatis arrays and sets is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report