In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of what problems will occur when the query result is empty in mybatis, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something when you finish reading this mybatis when the query result is empty. Let's take a look.
First: resultType is the basic type, such as string (here we will classify string as the basic type)
If the result of select is empty, the dao interface returns the result of null
Second, resultType is the basic type, such as int
The backstage reported an exception:
Org.apache.ibatis.binding.BindingException: Mapper method 'com.fkit.dao.xxDao.getUserById attempted to return null from a method with a primitive return type (int).
Explanation: the query result is null, an attempt was made to return null, but the return value defined by the method is int,null to int Times error
Solution: change the return value of select to String
The third resultType is map, such as map and hashmap
The return value of dao layer API is null.
The fourth resultType is list, such as list
The return value of the dao layer API is [], that is, an empty collection.
Note: null cannot be used to determine whether the query is empty at this time.
The fifth resultType is the class, such as com.fkit.pojo.User
Dao layer API returns a value of null
This is the end of the article on "what will happen when the query result in mybatis is empty?" Thank you for reading! I believe you all have a certain understanding of the knowledge of "what will happen when the query result is empty in mybatis". 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.