HibernateQueryException: Not supported for DML operations

L

lichuan.nj

Hi all, I got this strange exception

HibernateQueryException: Not supported for DML operations

delete from com.avid.interplay.tags.TagAssignment
assignment
where assignment.element = :element
and assignment.tag = :tag


by executing a Hibernate query:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
delete from com.avid.interplay.tags.TagAssignment
assignment
where assignment.element = :element
and assignment.tag = :tag
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Looks like DML clauses are not supported? But another piece similar
code runs fine.
I am using Hibernate 3 with a hsql server.



where TagAssignment looks like

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public class TagAssignment {
private Long id;
private ElementProxy element;
private Tag tag;

protected TagAssignment() {
}

public TagAssignment(ElementProxy element, Tag category) {
this.element = element;
this.tag = category;
}

public ElementProxy getElement() {
return element;
}

public Tag getTag() {
return tag;
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



This is my method call:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
HibernateCallback callback = new HibernateCallback() {
public Object doInHibernate(Session session) throws
HibernateException, SQLException {
Query query =
session.getNamedQuery("com.avid.interplay.tags.TagAssignment.deleteFromProxy");
query.setParameter("element", element);
query.setParameter("tag", tag);
return query.list();
}
};
getHibernateTemplate().execute(callback);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Thanks a lot.
 
L

lichuan.nj

It is solved by openning a session manually, instead of usong
HibernateTemplate, thanks anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top