-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Delete Query
PostPosted: Sat Jan 17, 2009 2:08 pm 
Newbie

Joined: Sat Jan 17, 2009 2:02 pm
Posts: 1
Hi! why doesn't this query work ??
i don"t know what to do.
Help !!!

Code:
public void deleteUserFromGrupa(int groupid, int userid)
{
   ISession session = GetSession();
   session.CreateQuery("DELETE from users_groups c where c.userid='" + userid + "' AND c.groupid='" + groupid + "'");
}

Error : ...must begin with SELECT or FROM...
txh


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 9:04 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
CreateQuery is just for selection ... if you use 2.0, there should be something like ExecuteUpdate and ExceuteDelete. If you still have 1.2, you have to create your own IDbCommand from the session:

IDbCommand cmd = session.Connection.CreateCommand();
...

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.