Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Deleting a List of Objects with HIbernate  RSS feed

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a good way to delete a List of hibernate objects all at once? Today I am iterating through a List of objects and running the delete method below on each.



Thanks!
Andrew Hahn
www.scranthdaddy.com
 
Hung Tang
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andy Hahn:
Hi,
Is there a good way to delete a List of hibernate objects all at once? Today I am iterating through a List of objects and running the delete method below on each.



Thanks!
Andrew Hahn
www.scranthdaddy.com


You could do a bulk delete using a query if you know what to actually delete. Otherwise, iterating and deleting is probably your best bet. From the code you provided, maybe it's better to delete the collection as a single transaction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!