相当相当隐蔽的错误 : unexpected token

时间:2025-04-21 13:10:09
网上查的,问题解决了,借鉴
其中一个在hql查询的时候报: unexpected token: ApplyInfo near line 1, column 23这样的错误,貌似看起来hibernate不认识ApplyInfo这个映射持久类,但是这个类非常确定的是已经映射了,而且在别处用的非常正常。郁闷,找啊找
在网上找: unexpected token的错误有
1、持久类写错了,要不就是写成了数据库表名
2、hibernate3.0不支持select中嵌套查询,据说from中也不行,只支持where中嵌套查询,好像3.1支持了select中嵌套
3、sql语句中字段是用了保留关键字

然后就是我发现的这个隐蔽错误了
发现的from后的空格是一个全角的空格,半角 空格,全角 空格。距离比一样啊,原来就看出from后面的空格大了,还以为是两个空格呢。

隐蔽,太隐蔽了。

: unexpected token: ApplyInfo near line 1, column 23 [SELECT contCount FROM ApplyInfo where applyId = (select applyId from where id=25)]
    at (:59)
    at (:244)
    at (:155)
    at (:109)
    at .<init>(:75)
    at .<init>(:54)
    at (:71)
    at (:134)
    at (:113)
    at (:1602)
    at (:273)
    at (:95)
    at (:484)
    at (:274)
    at (:1482)
    at (:525)
    at (:763)
    at (:856)
    at $(:225)
    at (:127)
    at (:283)
    at (:26)
    at (:42)
    at (:61)
    at (:42)
    at (:67)
    at (:42)
    at $(:3212)
    at (:321)
    at (:121)
    at (:1983)
    at (:1890)
    at (:1344)
    at (:209)
    at (:181)
Caused by: line 1:23: unexpected token: ApplyInfo
    at (:4021)
    at (:861)
    at (:3422)
    at (:3200)
    at (:3082)
    at (:2802)
    at (:570)
    at (:2586)
    at (:2449)
    at (:2413)
    at (:2331)
    at (:2296)
    at (:2082)
    at (:2249)
    at (:1455)
    at (:1365)
    at (:1106)
    at (:702)
    at (:296)
    at (:159)
    at (:238)
    ... 33 more

相关文章