MyBatis報錯:Cannot determine value type from string....


報錯信息:

org. springframework. web. util. NestedServletExcepti on:Request processing f ailed; 
nested exception is org.springframework. dao. DataIntegrityViolationExceptionError attempting to Cannot determine. value tvpe from string ” 2019-9-25 05:11: 48’nested ex ception is :java. sql. SQLDat aException: Cannot determine value tvpe from string ’2019-9-25 05: 11: 48

 

新建查詢后出現了這個錯誤,經發現是實體類接收數據庫數據類型不匹配導致的。(字段和屬性沒有對上

日期格式在經過DATE_FORMAT之后

DATE_FORMAT(update_time,'%Y-%c-%d %h:%i:%s') as 'update_time',

使用Date類型屬性接收報錯,修改后使用String類型的屬性接收。

 

還有一種情況也會導致報這種錯:

還有一種情況,構造函數問題,有參構造創建后,無參構造沒有創建,也會導致這個問題。弄了一下午,換數據庫、換字段、換屬性名都沒解決,最后想起來是不是缺少無參構造了

There was an unexpected error (type=Internal Server Error, status=500).
Error attempting to get column 'u_account' from result set. 
Cause: java.sql.SQLDataException: Cannot determine value type from string '201577D0510' ;
Cannot determine value type from string '201577D0510'; nested exception is java.sql.SQLDataException:
Cannot determine value type from string '201577D0510' org.springframework.dao.DataIntegrityViolationException: Error attempting to get column 'u_account' from result set.
Cause: java.sql.SQLDataException: Cannot determine value type from string '201577D0510' ;
Cannot determine value type from string '201577D0510';
nested exception is java.sql.SQLDataException: Cannot determine value type from string '201577D0510' at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:84) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) at com.sun.proxy.$Proxy65.selectList(Unknown Source)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM