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

目前在修改维护一个项目,以前系统设计的时候有个表的主键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)
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!