-->
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.  [ 7 posts ] 
Author Message
 Post subject: Delete using in clause
PostPosted: Thu Nov 16, 2006 6:55 am 
Newbie

Joined: Thu Nov 16, 2006 6:47 am
Posts: 3
I am trying to delete records from a table where the ID is in a set of values. Can I achive this using criteria queries?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 7:57 am 
Regular
Regular

Joined: Tue Feb 24, 2004 11:42 am
Posts: 56
Can you make it bit more clearer what you are trying to achieve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 8:25 am 
Newbie

Joined: Thu Nov 16, 2006 6:47 am
Posts: 3
I want to delete all the records from a table whose ID is present in a set of values. Can I do this using Criteria queries?
For more clarity, I want to implement the following query.

DELETE * FROM A WHERE ID IN (a, b, c, ...)

I hav all the IN parameters in a Vector.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 9:37 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Criteria don't support bulk updates/deletes. Use HQL.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 16, 2006 10:57 am 
Regular
Regular

Joined: Tue Feb 24, 2004 11:42 am
Posts: 56
[quote="sandeep.r"]I want to delete all the records from a table whose ID is present in a set of values. Can I do this using Criteria queries?
For more clarity, I want to implement the following query.

DELETE * FROM A WHERE ID IN (a, b, c, ...)

I hav all the IN parameters in a Vector.

Thanks[/quote]

try this

List list = criteria.list
list.removeall(list);
This is a roundabout way if you insist in using criteria. but ideally you should be using HQL or
session.createFilter.

Hope this helps .please do rate


Top
 Profile  
 
 Post subject: similar problem
PostPosted: Tue Nov 21, 2006 8:47 am 
Beginner
Beginner

Joined: Mon Nov 06, 2006 2:40 am
Posts: 29
Location: New Delhi, India
Hi sandeep,

I am getting similar problem in deletion with IN clause,

Can u please help if u have found the solution to this problem...

Regards,

Rohit(Sagi)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 9:06 am 
Newbie

Joined: Thu Nov 16, 2006 6:47 am
Posts: 3
Dear Rohit,
I had changed my startegy in my application so that I no longer need using the IN clause and continue using criterias.
But if you want this query better u use the HQL.

Thanks
Sandeep


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