首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >query.setLockMode("a",lockMode.upgrade_skiplocked)在hibernate中发出警告

query.setLockMode("a",lockMode.upgrade_skiplocked)在hibernate中发出警告
EN

Stack Overflow用户
提问于 2015-12-17 09:40:40
回答 2查看 1.8K关注 0票数 0

我试图将sql查询替换为Oracle,它如下所示:

代码语言:javascript
运行
复制
select trim(a.id) as id from tbl_insttype a where a.chi_city='1' order by cast(a.id as int) for update skip locked

以下是等效的hibernate替换:

代码语言:javascript
运行
复制
Query query=session.createQuery("select trim(a.id) as id from TblInsttype a where a.chiCity='1' order by cast(a.id as int) ");
    query.setLockMode( "a",LockMode.UPGRADE);

但我的日志警告说

日志:

代码语言:javascript
运行
复制
12830 [main] DEBUG org.hibernate.hql.internal.ast.ErrorCounter  - throwQueryException() : no errors
12846 [main] WARN org.hibernate.dialect.function.TemplateRenderer  - HHH000174: Function template anticipated 4 arguments, but 1 arguments encountered
12846 [main] DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl  - HQL: select trim(a.id) as id from com.imageinfo.eclear.cfg.xml.TblInsttype a where a.chiCity='1' order by cast(a.id as int) 
12846 [main] DEBUG org.hibernate.hql.internal.ast.QueryTranslatorImpl  - SQL: select trim(tblinsttyp0_.ID) as col_0_0_ from EXPOTDBU_PHILIPPINES.TBL_INSTTYPE tblinsttyp0_ where tblinsttyp0_.CHI_CITY='1' order by cast(tblinsttyp0_.ID as number(10,0))
12846 [main] DEBUG org.hibernate.hql.internal.ast.ErrorCounter  - throwQueryException() : no errors
12861 [main] WARN org.hibernate.loader.Loader  - HHH000445: Alias-specific lock modes requested, which is not currently supported with follow-on locking; all acquired locks will be [UPGRADE]
12861 [main] WARN org.hibernate.loader.Loader  - HHH000444: Encountered request for locking however dialect reports that database prefers locking be done in a separate select (follow-on locking); results will be locked after initial query executes
12877 [main] DEBUG org.hibernate.SQL  - select trim(tblinsttyp0_.ID) as col_0_0_ from EXPOTDBU_PHILIPPINES.TBL_INSTTYPE tblinsttyp0_ where tblinsttyp0_.CHI_CITY='1' order by cast(tblinsttyp0_.ID as number(10,0))
Hibernate: select trim(tblinsttyp0_.ID) as col_0_0_ from EXPOTDBU_PHILIPPINES.TBL_INSTTYPE tblinsttyp0_ where tblinsttyp0_.CHI_CITY='1' order by cast(tblinsttyp0_.ID as number(10,0))

12861说了一些明确的话,我没有得到它right.and下面的查询,它也没有任何的更新,跳过锁定在它。

我不明白我做错了什么,我应该尝试一些其他的事情吗?加上--它给不同的lockModes带来了相同的错误。

EN

回答 2

Stack Overflow用户

发布于 2015-12-17 15:54:06

上面写着Alias-specific lock modes requested, which is not currently supported with follow-on locking,所以我认为你应该尝试一下,不要把你的桌子和a混在一起。(只有一张桌子,需要吗?)

票数 0
EN

Stack Overflow用户

发布于 2022-05-04 07:55:42

也许HQL解析器没有重新定义别名,您必须将hql从select trim(a.id) as id from tbl_insttype a更改为select a.id from tbl_insttype a

我已经尝试过count(a.id)查询不支持setLockMode,会抛出could not locate alias to apply lock mode : a异常。

一个简单的select(a) from Entity a可以工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34331218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档