我試圖取代我的SQL查詢是Oracle警告,這是因爲:query.setLockMode(「A」,lockMode.upgrade_skiplocked)給出了休眠
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))
說一些明確的話,我沒有得到它的權利。下面的SQL查詢也沒有任何更新跳過鎖定在它。
我沒有得到我在做錯什麼,我應該嘗試一些其他的事情嗎? PLUS 它給不同的鎖模式相同的錯誤。
還在等待回覆!!!它已經兩個小時,只有10個意見:( –
什麼版本的Hibernate? – Naros
我使用4.3,並且也嘗試過5.0,但在這兩個版本中都是同樣的東西。 –