我正在尝试替换用于Oracle的sql查询,它是:
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
以下是等效的休眠替换:
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);
但我的日志警告
LOG:
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 说了一些明确的话,我说得不对。下面的sql查询也没有锁定更新内容。
我不知道我做错了什么,我应该尝试其他一些事情吗? 的 PLUS 它为不同的lockModes提供了相同的错误。
答案 0 :(得分:0)
它说Alias-specific lock modes requested, which is not currently supported with follow-on locking
,所以我认为您应该尝试使用a
对表进行别名。 (只有一张桌子,是否需要它?)