开发者

query must begin with SELECT or FROM: delete [delete

I am using JPA in addition to spring(3.0.0.M4). While deleting multiple records using query.executeUpdate() i am getting the following exception.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: query must begin with SELECT or FROM: delete [delete obj com.ocimum.btree.mw.core.objecttypes.profile.entity.ProfileEntity obj]
    开发者_运维百科    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:648)
        org.springframework.web.servlet.FrameworkServlet.doDelete(FrameworkServlet.java:578)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

I am using spring Transactional management.

Its working with entityManager.remove() but multiple delete is giving the above execption. I hav't used any query factory in application.


If the problem remains after correcting the syntax of your query, verify your Hibernate configuration: Setting the property hibernate.query.factory_class to org.hibernate.hql.ast.ASTQueryTranslatorFactory worked in my case.

For more information, I refer to the Hibernate forum post where I found this solution.


This has nothing to do with Spring. Your query syntax is incorrect, and the exception message is telling you that.


DELETE [FROM] com.ocimum.btree.mw.core.objecttypes.profile.entity.ProfileEntity obj WHERE ...

Check here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜