In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what mybatis has to judge the input basic type parameters. It is very detailed and has certain reference value. Friends who are interested must read it!
Judgment of incoming basic type parameters
ParameterType is the basic type in the sql statement of mybatis's xml file, such as:
Select * from customer where id=# {id}
Will report an error: There is no getter for property named 'id' in' class java.lang.Integer'
This is because there is no id property in the Integer object
Solution select * from Customer where id=# {_ parameter}
Change the parameter name of the received parameter to _ parameter. Note that it is useless to change it to other parameter names.
Test judges error when passing in basic type parameters
The following problems arise when using mybatis:
/ / Code List getName (String username) in the interface of the Dao layer; / / Code select name,client_id from table1 and username= # {id} in the corresponding mapper
/ / reported error
Org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException:
There is no getter for property named 'username' in' class java.lang.String'
Analysis.
The sentence There is no getter for property named 'username' in' class java.lang.String', roughly means that there is no getter method for an attribute named "username" in "class java.lang.String". Because mybatis uses ONGL parsing parameters by default, it automatically takes the string.numvalue in the form of an object tree, causing an error.
Solution.
The id in if test is replaced with _ parameter, and the actual statement does not need to modify and a.id = # {id}, because the content in # {} is not required when Mybatis passes in only one parameter.
Set the name of the input and exit parameter in Mapper, for example: public. GetName (@ Param ("username") String username); so that our previous writing will not be misreported after modification.
These are all the contents of this article entitled "what is the way mybatis judges the input basic type parameters?" Thank you for reading! Hope to share the content to help you, more related knowledge, 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.