mysql - HQL语句关于0开头的数字型字符串的奇怪问题
大家讲道理
大家讲道理 2017-04-17 11:16:33
[MySQL讨论组]

目前在修改维护一个项目,以前系统设计的时候有个表的主键XID设置为数字型的字符串类型,如
0000000000,0000000001,查询的时候遇到一个奇怪的问题,有的XID报错,有的XID正常。
比如说下面这条语句就能正常执行:
select count(entity.id) from XFHiddenTrouble as entity where entity.logicDeleteCode = 0 and entity.XID in (0000000000)
但是下面两条包含9的语句就报错的,很奇怪。
select count(entity.id) from XFHiddenTrouble as entity where entity.logicDeleteCode = 0 and entity.XID in (00000000089)

select count(entity.id) from XFHiddenTrouble as entity where entity.logicDeleteCode = 0 and entity.XID in (0000000029)
错误如下:
org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 9 near line 1, column 138 [select count(entity.id) from com.qdhh.xfxt.entity.XFHiddenTrouble as entity where entity.logicDeleteCode = 0 and entity.XID in (0000000109)]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 9 near line 1, column 138 [select count(entity.id) from com.qdhh.xfxt.entity.XFHiddenTrouble as entity where entity.logicDeleteCode = 0 and entity.XID in (0000000109)]

测试了一下,发现xid中包含8或者9的时候就报错了,不知道是不是因为是0开头的,当成八进制来识别转换

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

全部回复(1)
阿神

没人知道原因么?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号