-
1. Re: Way to implement a removeAll() method?
khkachn Jun 7, 2007 8:54 PM (in response to seansawyer)Can't you do something like:
int deletedEntities = entityManager.createQuery("delete from Customer");
if you want to remove all records from a customer table? I have not tried this yet, but it works in Hibernate based on their documentation:
http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/batch.html#batch-direct -
2. Re: Way to implement a removeAll() method?
seansawyer Jun 8, 2007 9:34 AM (in response to seansawyer)Except, unfortunately, that the project in question does not use Hibernate.
It seems that there is no way to accomplish this through EJB:
http://forum.java.sun.com/thread.jspa?threadID=5174100&messageID=9671593
The impetus for this post was that, with a sufficiently large number of entities, I experience transaction timeouts due to the length of time it takes to iterate over the entities and delete everything using EJB's remove().
That said, perhaps the best (in this case, fastest) way to do this would be to use JDBC to delete the records and then iterate over any entities hanging around in the EJB cache and call remove() on those.