Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

HibernateQueryException: Not supported for DML operations

Thread view: 
lichuan.nj@gmail.com - 26 Nov 2007 13:04 GMT
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.
lichuan.nj@gmail.com - 26 Nov 2007 18:39 GMT
It is solved by openning a session manually, instead of usong
HibernateTemplate, thanks anyway.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.