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
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.
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.
Fixed in HEAD.