Removing Collection Data Container

I need to remove the Collection (composition) from the data container and have the following code:

 private void removeOldPaymentSchedule(){
        if(getEditedEntity().getPropertyAllotmentProposedPaymentSchedule()!=null) {

            List<PropertyAllotmentProposedPaymentSchedule> toRemove = new ArrayList<>();
            Iterator<PropertyAllotmentProposedPaymentSchedule> iteratorLineList = propertyAllotmentProposedPaymentScheduleDc.getItems().iterator();
            while (iteratorLineList.hasNext()) {
                PropertyAllotmentProposedPaymentSchedule line =;

           for (PropertyAllotmentProposedPaymentSchedule schedule : toRemove) {

When I run it, the collection data displayed in a screen (in a table) is removed but after I save it and reopen, see it was not deleted.

Only when I use the following 2nd line of code then it works.


Is it the right approach?

Yes, that’s correct.

1 Like