cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: onPostAdd and nested object contexts
Date Tue, 01 Sep 2015 10:40:09 GMT
Yeah, I must admit it is a bit messy. We may need to redesign callback logic in respect to
the nested contexts. For now your most obvious solution is to check for the object state within
'onPostAdd' before changing it again.

if(getSomeProperty() == null) {
  // we haven't been called yet, so init the property
  setSomeProperty(..);
}

Andrus

> On Sep 1, 2015, at 1:04 AM, Lon Varscsak <lon.varscsak@gmail.com> wrote:
> 
> So I am having trouble because when I call commitChangesToParent on one of
> my nested ECs, I'm getting onPostAdd called.  So in my case, I'm using
> onPostAdd to "setup" my object by creating relationships and setting
> default values.  However, it's getting called twice.  Once when I create
> the object in the child context and once on the parent context (during
> commit).
> 
> Any ideas on how to combat this?
> 
> -Lon


Mime
View raw message