Reputation: 18120
I tried to execute a delete query as following in eclipse's HQL tool
delete from Address address where address.id = 6
but i got the
org.hibernate.hql.QueryExecutionRequestException: Not supported for DML operations
Please tell me that i've done wrong. Thank you.
Upvotes: 12
Views: 13737
Reputation: 11
Please try the following:
final String hql = "delete from Job where jobId = :id";
Query query = session.createQuery(hql).setLong("id", jobId);
query.executeUpdate();
Upvotes: 1
Reputation: 31
I had same issue. Your issue is not for using DML... the first suggestion posted a link for a solution for DML, but your question is for SQL.
This works below for SQL.
String sql = "delete from ServiceProviderMapping where id=7";
Query query = hibernateSession.createQuery(sql);
query.executeUpdate();
Upvotes: 3
Reputation: 51965
This post suggests trying to open a session manually, and then run the delete.
Upvotes: 0