Bug 117 : isDirty() checking not sufficent when save cascade on OneToMany ... with enhanced beans.
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.0.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
29/05/2009
Updated 
29/05/2009
Type 
Bug
 
Attachments 
No attachments

Found by Eddie.

>>>

The cascade works down to line 441 in DefaultPersister - the line

if (((EntityBean) detailBean)._ebean_getIntercept().isDirty()) {

returns false for the newly added phoneContact - which means it never gets saved. The object is new so isDirty is probably never going to be true because oldValues == null is always true

 
Rob 29 May 23:13
Yes, missing "isNew" check

if (oneToMany) {
// set the 'parent/master' bean to the detailBean as long
// as we don't make it 'dirty' in doing so
if (detailBean instanceof EntityBean) {
if (((EntityBean) detailBean)._ebean_getIntercept().isDirty()) {
// set the parent bean to detailBean
prop.setJoinValuesToChild(request, parentBean, detailBean, mapKeyValue);
} else {
// unmodified so potentially can skip
// depending on prop.isSaveRecurseSkippable();
skipSavingThisBean = saveSkippable;
}
...

That is, we should set the join values to the child if the child is dirty or new.... and the "or new" is missing from that check.

... so yeah, exactly as you said. Need to additionally check for "is new" on enhanced beans.

Rob 29 May 23:17
Note about Embedded beans

As part of this I have noted that in adding a isNew() ... wrt the isDirty() check it makes sense for the entity to take care of also checking embedded beans.

So, I'll be looking at that as part of the fix for this problem.
Note: This requires a change to the enhancement.

Rob 03 Jun 12:50
Fixed in HEAD

Fixed in HEAD.

woResponse

Upload a file