You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Lon Varscsak <lo...@gmail.com> on 2018/08/07 17:46:49 UTC

Problem with Callback not getting called in parent/child setup

Hey all,

I've got a data object who has a preUpdate callback so that I can set
required values (like a timestamp) before update.  According to the docs
this should work in the parent-child setup, but that doesn't seem to be the
case.  Thoughts?  Here's a snippet of the stacktrace:

Validation failure for
com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp' is
a required value.

Validation failure for
com.smarthealth.businesslogic.personalization.ArchiveImage.timestamp:
"timestamp"  is required.

Validation failure for
com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp' is
a required value.

at org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(
ObjectStoreGraphDiff.java:113)

at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:734)

at org.apache.cayenne.access.DataContext.commitChangesToParent(
DataContext.java:682)

at com.smarthealth.wicket.designpal.components.EditorPage.save(
EditorPage.java:127)


The preUpdate callback is never fired.

Thanks,

Lon

Re: Problem with Callback not getting called in parent/child setup

Posted by Lon Varscsak <lo...@gmail.com>.
Yes, in a parent/child object context.  Works fine if I'm committing to the
db.

-Lon

On Tue, Aug 7, 2018 at 10:54 AM John Huss <jo...@gmail.com> wrote:

> Are you taking about parent/child ObjectContexts? I see you're calling
> commitChangesToParent not commitChanges. Does it work when you call
> commitChanges instead?
>
> Here's the code I have for the callbacks:
>
> callbackRegistry =
> runtime.getDataDomain().getEntityResolver().getCallbackRegistry();
>
> callbackRegistry.addCallback(LifecycleEvent.PRE_UPDATE,
> ICSDataObject.class, "willUpdate");
>
> public void willUpdate() {
> }
>
> On Tue, Aug 7, 2018 at 12:47 PM Lon Varscsak <lo...@gmail.com>
> wrote:
>
> > Hey all,
> >
> > I've got a data object who has a preUpdate callback so that I can set
> > required values (like a timestamp) before update.  According to the docs
> > this should work in the parent-child setup, but that doesn't seem to be
> the
> > case.  Thoughts?  Here's a snippet of the stacktrace:
> >
> > Validation failure for
> > com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp'
> is
> > a required value.
> >
> > Validation failure for
> > com.smarthealth.businesslogic.personalization.ArchiveImage.timestamp:
> > "timestamp"  is required.
> >
> > Validation failure for
> > com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp'
> is
> > a required value.
> >
> > at org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(
> > ObjectStoreGraphDiff.java:113)
> >
> > at
> > org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:734)
> >
> > at org.apache.cayenne.access.DataContext.commitChangesToParent(
> > DataContext.java:682)
> >
> > at com.smarthealth.wicket.designpal.components.EditorPage.save(
> > EditorPage.java:127)
> >
> >
> > The preUpdate callback is never fired.
> >
> > Thanks,
> >
> > Lon
> >
>

Re: Problem with Callback not getting called in parent/child setup

Posted by John Huss <jo...@gmail.com>.
Are you taking about parent/child ObjectContexts? I see you're calling
commitChangesToParent not commitChanges. Does it work when you call
commitChanges instead?

Here's the code I have for the callbacks:

callbackRegistry =
runtime.getDataDomain().getEntityResolver().getCallbackRegistry();

callbackRegistry.addCallback(LifecycleEvent.PRE_UPDATE,
ICSDataObject.class, "willUpdate");

public void willUpdate() {
}

On Tue, Aug 7, 2018 at 12:47 PM Lon Varscsak <lo...@gmail.com> wrote:

> Hey all,
>
> I've got a data object who has a preUpdate callback so that I can set
> required values (like a timestamp) before update.  According to the docs
> this should work in the parent-child setup, but that doesn't seem to be the
> case.  Thoughts?  Here's a snippet of the stacktrace:
>
> Validation failure for
> com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp' is
> a required value.
>
> Validation failure for
> com.smarthealth.businesslogic.personalization.ArchiveImage.timestamp:
> "timestamp"  is required.
>
> Validation failure for
> com.smarthealth.businesslogic.personalization.ArchiveImage: 'timestamp' is
> a required value.
>
> at org.apache.cayenne.access.ObjectStoreGraphDiff.validateAndCheckNoop(
> ObjectStoreGraphDiff.java:113)
>
> at
> org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:734)
>
> at org.apache.cayenne.access.DataContext.commitChangesToParent(
> DataContext.java:682)
>
> at com.smarthealth.wicket.designpal.components.EditorPage.save(
> EditorPage.java:127)
>
>
> The preUpdate callback is never fired.
>
> Thanks,
>
> Lon
>