• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Batch Delete in Hibernate  RSS feed

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did some groundwork on batch deletes in Hibernate and came across a useful link at Aaron Johnson's blog.

I implemented the suggestion in the following manner:



Upon implementing the given suggestion as shown above, following MappingException results:



It appears that the session's delete method is not able to make sense of the query passed as a string.

Can anyone tell me what I am doing wrong? Or, is there is another way to go about this mass delete thing?

Thanks,
Saket
[ May 13, 2007: Message edited by: Saket Barve ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Hibernate documentation mentions that this method has been deprecated.


Deprecated. consider using HQL delete statements

Delete all objects returned by the query. Return the number of objects deleted.

Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results calling Session.delete(Object) individually.



Moreover, this method is available on org.hibernate.classic.Session object and not org.hibernate.Session
 
Saket Barve
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Jaikiran.

The solution was to modify the delete query and pass the ID's as a parameter-list.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!