-clear() does not work:
List serviceAttribute = serviceNode.getServiceAttribute();
serviceAttribute.clear();
serviceNode.setServiceAttribute(serviceAttribute);
serviceNode = serviceNode.save();
serviceAttribute has not changed after serviceNode reloaded.
-With remove() this works:
List serviceAttribute = serviceNode.getServiceAttribute();
serviceAttribute.remove(configAttribute);
serviceNode.setServiceAttribute(serviceAttribute);
serviceNode = serviceNode.save();
serviceAttribute has not changed even if serviceNode has reloaded.
The bug is somewhere inside the BeanList#initClear() method:
private void initClear() {
synchronized (this) {
if (list == null) {
if (modifyListening){
lazyLoadCollection(true);
} else {
list = new ArrayList();
}
}
touched();
}
}
The modifyListening attribute is always false. It never be set true unless lazyLoadCollection() invoked.
Bean#init() works correctly, it not checks modifyListening attibute.
It seems like the list must be lazy loaded to work it correctly.
This issue is the same with sets.