new Field("level", level)};
@SuppressWarnings("unchecked")
Iterator<Discount> discounts = findEntityList(Discount.class, field).iterator();
if(discounts.hasNext()) {
Discount discount = discounts.next();
discount.setValue(d.value);
manager.merge(discount);
// remove extra lines
while(discounts.hasNext()) {
discount = discounts.next();
manager.remove(discount);
}
} else {
Discount discount = new Discount();
discount.setDiscountCardType(type);
discount.setServiceClass(cls);
discount.setLevel(level);
discount.setValue(d.value);
manager.persist(discount);
}
}
}