在使用hibernate的query进行update时,如果提示
org.hibernate.QueryException: query must begin with SELECT or FROM,不表示hibernate版本的query不支持更新,检查hibernate的配置文件会发现有个属性设置为
<property name="hibernateProperties">
<props>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
这个属性会使得hibernate不支持更新语句,如果使用executeUpdate执行更新语句就会报错。设置这个属性的是指定hibernate的hql解析器。
org.hibernate.QueryException: query must……的解决方案
本文介绍了解决使用Hibernate的Query进行update操作时遇到的错误:org.hibernate.QueryException:querymustbeginwithSELECTorFROM。通过调整hibernate配置文件中的特定属性,可以启用对更新语句的支持。

被折叠的 条评论
为什么被折叠?



