`

org.hibernate.QueryException: query must begin with SELECT or FROM: delete

阅读更多

转自:http://k0441258778983.iteye.com/blog/1042580

hibernate自带HQL一般只用于查询语句; 
而增删改需要在query执行之后再调用query.executeUpdate(); 

但是经测试后一直报异常如下: 
org.hibernate.QueryException: query must begin with SELECT or FROM: delete 
经过网上查询其原因是: 
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> 即可!

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics