public static void deleteByAccident(Accident accident) { List<Injurie> injuries = Injurie.byAccident(accident); for (Injurie injury : injuries) { injury.delete(); } }
public static void update(Accident accident, List<Injurie> injuries) { if (injuries == null) { return; } for (Injurie injury : injuries) { if (injury.id == null && injury.description.trim().isEmpty()) { continue; } if (injury.id != null && injury.description.trim().isEmpty()) { injury = injury.merge(); injury.delete(); continue; } injury = injury.merge(); injury.accident = accident; injury.save(); } }