You might find better performance doing a "delete by query", if
1. you can formulate the logic into a query2. you can do the delete as the last or only part of a transaction.
Craig
On Nov 8, 2006, at 10:07 AM, Greg Ederer wrote:
Hi,
I have a method that removes a persistent object from a collection based on a property of the object being removed, like so:
/**
* Removes all ShoppingCartItems containing this
* offering
*/
public void removeItem(Offering offering)
{
List<ShoppingCartItem> iList = new ArrayList<ShoppingCartItem>(getItems());
for(ShoppingCartItem i : iList)
{
if(i.getOffering().equals(offering))
{
getItems().remove(i);
}
}
}
Is this the best way to do this?
Cheers,
Greg
p.s.: I'm so glad I found this list. I feel like I've been groping in the dark with JPA. Thanks for all the help! --G
--
| E R G O N O S I S | Greg Ederer | Lead Developer | greg@ergonosis.com | 360.379.1157 | | OpenDocument - OK |
Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!
| E R G O N O S I S | Greg Ederer | Lead Developer | greg@ergonosis.com | 360.379.1157 | | OpenDocument - OK |