-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to delete rows using Query/named query ???
PostPosted: Thu Dec 09, 2004 3:36 am 
Newbie

Joined: Tue Dec 07, 2004 7:51 am
Posts: 7
Is it possible to delete a bunch of rows based on some column value using Query interface or the named query in the mapping xml ?

For ex, if we write the following query in xml :

<query name="delete.rptExpressions.for.particular.expressionID">
delete from RptExpression as rptExpression
where rptExpression.expressionID = ?
</query>

and the following code in java :
Query query = HibernateUtil.currentSession().getNamedQuery("delete.rptExpressions.for.particular.expressionID");
query.setInteger(0, expressionID);
query.list();


Will execution of the above code do delete for us ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 4:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
session.delete()


Top
 Profile  
 
 Post subject: Re
PostPosted: Thu Dec 09, 2004 5:23 am 
Newbie

Joined: Tue Dec 07, 2004 7:51 am
Posts: 7
But if you use session.delete, you will have to hardcode the query for deletion over here only, whereas I want to write the query in mapping xml file and then use that as a named query in java.
Is there any way to do that ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.