HibernateQueryException: Not supported for DML operations

Discussion in 'Java' started by lichuan.nj@gmail.com, Nov 26, 2007.

  1. Guest

    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.
     
    , Nov 26, 2007
    #1
    1. Advertising

  2. Guest

    It is solved by openning a session manually, instead of usong
    HibernateTemplate, thanks anyway.
     
    , Nov 26, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. NEETU GARG
    Replies:
    1
    Views:
    712
    Simon Peacock
    Apr 10, 2004
  2. Replies:
    0
    Views:
    475
  3. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    4,240
    robert
    Feb 11, 2006
  4. Fabri

    DML and xmlhttp

    Fabri, Nov 3, 2005, in forum: Javascript
    Replies:
    5
    Views:
    124
    Michael Winter
    Nov 4, 2005
  5. Replies:
    0
    Views:
    92
Loading...

Share This Page