閱讀982 返回首頁    go 技術社區[雲棲]


Hibernate之update(2)——報錯query must begin with SELECT or FROM

 
hibernate自帶HQL一般隻用於查詢語句,而增刪改需要在query執行之後再調用query.executeUpdate();

但是經測試後一直報異常如下:
org.hibernate.QueryException: query must begin with SELECT or FROM:
 
原因:
hibernate 配置文件hibernate.cfg.xml裏 解析hibernate 查詢語言為2.X版本。

 解決辦法:
<property name="hibernate.query.factory_class">
        org.hibernate.hql.classic.ClassicQueryTranslatorFactory </property>

將其改為3.X
<property name="hibernate.query.factory_class">
       org.hibernate.hql.ast.ASTQueryTranslatorFactory
</property> 
 
或者
 

2.x :hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory   

3.x:hibernate.query.factory_class=org.hibernate.hql.ast.ASTQueryTranslatorFactory 

 

原帖地址:https://k0441258778983.iteye.com/blog/1042580

參考地址:https://kangzye.blog.163.com/blog/static/3681922320098311461766/


 


 

最後更新:2017-04-02 22:16:31

  上一篇:go 關於ORACLE時間存儲的問題
  下一篇:go 單例設計模式的實現代碼