• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity bean bulk delete

 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.. Here is what I am trying to achieve.. I have my application that uses entity beans as ORM. I am trying to bulk delete rows of a very large table, via entity bean CMP. I understand that the code would look something like this...,



In my case, the collection rowsToDelete (which would be populated by a finder) would have close to a million records. Would this create as many objects in the EJB pool? Would'nt this exhaust my EJB container's heap? Is this why the docs advise against the usage of findAll()..

For your info, I use JBoss 6.0.0 with EJB 2.0. If bulk delete such as the above is problematic, I am looking for a way to fetch only a limited number of records, say 500 iteratively and delete records. As far as I checked, this option is available in EJB 3.0 but not in EJB 2.0. So, how do I accomplish a delete in this case. Any ideas or pointers are appreciated.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34073
335
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you *have* to use EJB for this? CMPs are not a good solution for bulk operations. A better way to do this would be to use JDBC to do the delete.

You do have to make sure that those EJB instances aren't in use by other parts of the code since those CMPs won't know the transactions got deleted.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne.. I have indeed decided to use JDBC for this.. Thanks for the tip on avoiding clash with live EJB instances..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic