java.sql.SQLException: Fail to convert to internal representation
message: "Error attempting to get column 'PARAM_NAME' from result set.
Cause: java.sql.SQLException: Fail to convert to internal representation↵;
uncategorized SQLException; SQL state [99999]; error code [17059];
Fail to convert to internal representation;
nested exception is java.sql.SQLException:
Fail to convert to internal representation"
Java
package com.app.dto;
public class DiversityCustomAttrDTO {
private Long numberValue;
private String paramName;
public DiversityCustomAttrDTO(Long numberValue, String paramName) {
this.numberValue = numberValue;
this.paramName = paramName;
}
// getters setters
}
MyBatis
<resultMap id="customAttrResultMap" type="com.app.dto.DiversityCustomAttrDTO">
<result property="paramName" column="PARAM_NAME" jdbcType="VARCHAR"/>
<result property="numberValue" column="NUMBER_VALUE" jdbcType="NUMERIC" />
</resultMap>
怎麼看都沒問題,刪掉程式碼一行行加回來,原來是IDEA自動生成建構函式的引數順序和resultset裡result順序不匹配時就會報錯。
刪掉建構函式 - 工作
加上預設無參的建構函式 - 工作
調整引數順序和resultset裡一樣 - 工作
那麼基本可以推測,mybatis ibatis 原始碼裡當遇到有建構函式的時候,而且有沒有無參的建構函式,引數順序就必須和resultset裡是一致的。
推測底層是通過反射來例項化的,看下反射類中的Constructor,只能拿到
private Class<?>[] parameterTypes;
所以當我們的建構函式第一個是long,而result裡是varchar,也就是String時,就報錯了。
相關文章
- fail-fast和fail-safeAIAST
- Text Representation
- VulNyx - Internal
- 7.60 CONVERT
- Transformers for Graph RepresentationORM
- Fail-Fast in JavaAIASTJava
- Fail - Fast機制AIAST
- 深入理解Java中的fail-fast和fail-safeJavaAIAST
- NEQR: novel enhanced quantum representation
- PHP 每日一函式 — 字串函式 convert_uuencode () & convert_uudecode ()PHP函式字串
- Accessing Internal Members in the UNO FrameworkFramework
- java.sql.SQLException: Incorrect string valueJavaSQLException
- Python convert string to unicode numberPythonUnicode
- [Linux] convert .img to .iso fileLinux
- DocTo convert doc(x) to pdf
- Convert型別轉換型別
- How to Convert a Class File to a Ja
- POI2012ROZ-Fibonacci Representation
- [ARC060F] Best Representation
- Evolving Losses for Unsupervised Video Representation LearningIDE
- 談談fail-fast與fail-safe是什麼以及工作機制AIAST
- Fail-fast 機制分析AIAST
- [Java基礎]Fail-FastJavaAIAST
- How Oracle Store Number internal(zt)Oracle
- ORA-00600: [OSDEP_INTERNAL]
- java.sql.SQLException: 數字溢位JavaSQLException
- PIL.Image convert to numpy array
- 淺析Convert,Parse和TryParse
- matlab convert to PGM P2Matlab
- koa-convert原始碼分析原始碼
- 19c RAC Convert to OneNde
- 19c OneNode Convert to RAC
- C# convert ImageSource to byte arrayC#
- 538-Convert BST to Greater Tree
- Convert a normal Git repository to a bare oneORMGit
- Momentum Contrast (MoCo) for Unsupervised Visual Representation LearningAST
- python中fail函式如何使用PythonAI函式
- fail2ban 防止暴力破AI