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時,就報錯了。
相關文章
- Text Representation
- fail-fast和fail-safeAIAST
- java.sql.SQLException: Scope not recognizedJavaSQLExceptionZed
- Fail-Fast in JavaAIASTJava
- Fail - Fast機制AIAST
- 深入理解Java中的fail-fast和fail-safeJavaAIAST
- oracle internalOracle
- VulNyx - Internal
- [ARC060F] Best Representation
- java.sql.SQLException: Incorrect string valueJavaSQLException
- java.sql.SQLException: 數字溢位JavaSQLException
- Oracle-InternalOracle
- Fail-fast 機制分析AIAST
- 關於 rac vip fail backAI
- OFS(Oracle Fail Safe)簡介OracleAI
- [Java基礎]Fail-FastJavaAIAST
- C#中public、private、protected、internal、protected internal (轉載)C#
- Convert object/bean to mapObjectBean
- sql server convert用法SQLServer
- CONVERT DATABASE命令(三)Database
- CONVERT DATABASE命令(二)Database
- CONVERT DATABASE命令(一)Database
- 談談fail-fast與fail-safe是什麼以及工作機制AIAST
- db_file_name_convert和log_file_name_convert詳解
- oracle INTERNAL_FUNCTIONOracleFunction
- mongodb replicat internal(一)MongoDB
- Btree Index storage internalIndex
- Internal Server Error..ServerError
- fail2ban 防止暴力破AI
- Connections to NOMOUNT/MOUNTED or RESTRICTED Databases FailRESTDatabaseAI
- Fail-Fast機制詳解AIAST
- fail2ban 安裝指南AI
- Convert.ToInt32( null or "")Null
- json convert to stringJSON
- How to Convert Subversion Repo to GitGit
- Convert Array of Objects to Data TableObject
- RMAN CONVERT DATABASE 的限制Database
- SQL Server CONVERT() 函式SQLServer函式