/** Remove all items from the given list by batch. */ public static int clearListInfoBatch(Delegator delegator, String shoppingListId) throws GenericEntityException { // remove the survey responses first ModelEntity shoppingListItemSurveyModelEntity = delegator.getModelReader().getModelEntity("ShoppingListItemSurvey"); List<EntityCondition> toBeRemovedCondition = new LinkedList<EntityCondition>(); EntityCondition condition = EntityCondition.makeCondition(UtilMisc.toMap("shoppingListId", shoppingListId)); toBeRemovedCondition.add(condition); delegator.removeAllByAndBatch(shoppingListItemSurveyModelEntity, toBeRemovedCondition); // next remove the items delegator.removeByAnd("ShoppingListItem", UtilMisc.toMap("shoppingListId", shoppingListId)); ModelEntity shoppingListItemModelEntity = delegator.getModelReader().getModelEntity("ShoppingListItemSurvey"); List<EntityCondition> toBeRemovedShoppingListItemCondition = new LinkedList<EntityCondition>(); EntityCondition shoppingListItemCondition = EntityCondition.makeCondition(UtilMisc.toMap("shoppingListId", shoppingListId)); toBeRemovedShoppingListItemCondition.add(shoppingListItemCondition); return delegator.removeAllByAndBatch( shoppingListItemModelEntity, toBeRemovedShoppingListItemCondition); }