Bug 432 : OneToMany attribute not saved after clear
Priority 
High
Reported Version 
 
Logged By 
Lev
Status 
Fixed
Fixed Version 
3.x
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
13/11/2012
Updated 
13/11/2012
Type 
Bug
 
Attachments 
No attachments

-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.

 
woResponse

Upload a file