数据截断:截断不正确的 DOUBLE 值:'3ML80909540'
Posted
技术标签:
【中文标题】数据截断:截断不正确的 DOUBLE 值:\'3ML80909540\'【英文标题】:Data truncation: Truncated incorrect DOUBLE value: '3ML80909540'数据截断:截断不正确的 DOUBLE 值:'3ML80909540' 【发布时间】:2015-02-23 06:10:34 【问题描述】:我有一个遗留数据库,对应的域类是这样的
class Assets
String id
AssetsFinancial assetsFinancial = new AssetsFinancial()
static constraints =
assetsFinancial(nullable: true)
static mapping =
version false
id generator: "assigned", column: '`id`'
assetsFinancial column: '`id`', insertable: false, updateable: false
和
class AssetsFinancial
Integer appraisal
Boolean doubleTerVar
static mapping =
version false
id generator: "assigned"
static constraints =
appraisal nullable: true
doubleTerVar nullable: true
当我更新 AssetsFinancial 实例的属性(如 assetsFinancialInstance.appraisal=2222
)并且休眠尝试“提交”它给我的更改时
| Error 2014-12-25 18:56:34,459 [http-bio-8080-exec-9] ERROR spi.SqlExceptionHelper - Data truncation: Truncated incorrect DOUBLE value: '3ML80909540'
| Error 2014-12-25 18:56:34,726 [http-bio-8080-exec-9] ERROR errors.GrailsExceptionResolver - mysqlDataTruncation occurred when processing request: [POST] /someController/someAction/1295448
Data truncation: Truncated incorrect DOUBLE value: '3ML80909540'. Stacktrace follows:
Message: could not execute statement
Line | Method
->> 53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
| 82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
| 67 | doFilter in com.studentsonly.grails.plugins.uiperformance.CacheFilter
| 270 | doFilter in com.planetj.servlet.filter.compression.CompressingFilter
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '3ML80909540'
->> 3560 | checkErrorPacket in com.mysql.jdbc.MysqlIO
我花了很多时间寻找原因,但无法找出原因,任何线索都会对我有所帮助。如果需要更多信息,请询问。
更新:休眠日志
2014-12-26 14:51:35,099 [http-bio-8080-exec-3] DEBUG hibernate.SQL - update assets_financial set appraisal=?, double_ter_var=? where id=?
2014-12-26 14:51:35,100 [http-bio-8080-exec-3] TRACE sql.BasicBinder - binding parameter [1] as [INTEGER] - [1003]
2014-12-26 14:51:35,100 [http-bio-8080-exec-3] TRACE sql.BasicBinder - binding parameter [2] as [BOOLEAN] - [false]
2014-12-26 14:51:35,101 [http-bio-8080-exec-3] TRACE sql.BasicBinder - binding parameter [3] as [BIGINT] - [1298944]
【问题讨论】:
试试这个trk7.com/blog/… 尝试使用参数配置 SQL 日志记录。我不认为是评估栏失败了。 我已经使用参数配置了 SQL 日志记录,但它并没有告诉我问题出在哪一列。 【参考方案1】:我终于找到了罪魁祸首
我们可以从 SQL 日志中看到
2014-12-26 14:51:35,101 [http-bio-8080-exec-3] TRACE sql.BasicBinder - binding parameter [3] as [BIGINT] - [1298944]
这里数据类型是 BIGINT 但它应该是 VARCHAR 然后我在我的 AssetsFinancial
中添加 String id
class AssetsFinancial
String id
//rest of code
现在一切都很好:)
【讨论】:
以上是关于数据截断:截断不正确的 DOUBLE 值:'3ML80909540'的主要内容,如果未能解决你的问题,请参考以下文章