在使用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……的解决方案
最新推荐文章于 2024-05-02 01:24:22 发布