Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Batch Delete in Hibernate

 
Saket Barve
Ranch Hand
Posts: 229
  • 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 ]
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
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: 229
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic