File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Entity bean bulk delete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Entity bean bulk delete" Watch "Entity bean bulk delete" New topic
Author

Entity bean bulk delete

Sugantha Jeevankumar
Ranch Hand

Joined: Jun 06, 2007
Posts: 93
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.


SCJP 5.0
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30512
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sugantha Jeevankumar
Ranch Hand

Joined: Jun 06, 2007
Posts: 93
Thanks Jeanne.. I have indeed decided to use JDBC for this.. Thanks for the tip on avoiding clash with live EJB instances..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity bean bulk delete