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

What is the handling plan of mybatis parameter type mismatch error argument type mismatch

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

Share

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

This article mainly analyzes the relevant knowledge points of what is the processing scheme of mybatis parameter type mismatch error argument type mismatch, the content is detailed and easy to understand, the operation details are reasonable, and has a certain reference value. If you are interested, you might as well follow the editor to have a look, and follow the editor to learn more about "what is the solution for mybatis parameter type mismatch error argument type mismatch".

Parameter type mismatch error argument type mismatch error log

Java.lang.RuntimeException: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of' class xxxxxxxx' with value '37997' Cause: java.lang.IllegalArgumentException: argument type mismatch

Org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error selecting key or setting result to parameter object. Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'id' of' class com.fshows.lifecircle.marketcore.service.dal.lifecircle.dataobject.TpLifecircleQuotaDO' with value '37997' Cause: java.lang.IllegalArgumentException: argument type mismatch

Error description

According to the literal meaning: parameter type mismatch

It is actually stored by a parameter, which is not consistent with the type of parameter passed in.

Error code

Cause of error

When mybatis:gen generates code, this id parameter generates the type resultType= "java.lang.Long", but the actual database type is int and should correspond to resultType= "java.lang.Integer"

Just change Long to Integer, corresponding to the database.

Pit error description of argument type mismatch in mybatis: parameter type mismatch

The problem with mybatis mapping in common errors is nothing more than

Column name error, property field name error, resultMap id mismatch, mapping entity class attribute type and database field type mismatch

This is generally relatively easy to think of and find.

But one day, because the mapping entity class needs data processing in some places, you write a parameter construction instead of adding the no-parameter construction. Then mybatis will have an exception when mapping (the mapping should first create an object). At this time, the parameter type mismatch refers to the construction parameter type mismatch rather than the data field and attribute mismatch!

For example

Under new PeopleVO (People p) and new People () debug, you can see the error parameter People type error.

Therefore, the rules that should be followed in development should be followed. I believe many people must have heard of writing parametric structures when they first learned java. At that time, I thought that if you use parameterless construction, the new object compiler will also prompt that it is not too late and may not be useful in new.

But in the mybatis mapping, I can't believe that people reflect to create objects. I can't help feeling that the summaries of our predecessors have been built on the basis of stepping on countless holes, and the code that looks like there will be no problem may appear bug in some unexpected form.

On the "mybatis parameter type mismatch error argument type mismatch is what is the solution" introduced here, more related content can search the previous article, hope to help you answer questions, please support the website!

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