Re: Making sense of callbacks

From: Lachlan Deck (lachlan.dec..mail.com)
Date: Fri Oct 30 2009 - 17:21:40 EDT

  • Next message: Evgeny Ryabitskiy: "Re: Aggregated cayenne.xml from several modules (projects)"

    Hi Andrey,

    On 30/10/2009, at 9:18 PM, Andrey Razumovsky wrote:

    > Below is the test showing that everything's OK (or you can change
    > event type
    > to PRE_PERSIST with same effect). Lachlan, please double-check that
    > all
    > callbacks are mapped correctly and give us more details about errors.

    We have no specific mapping in our model -- so are just relying on
    default behaviour. What I found (after updating to 3.0B1) that when
    committing from the client to the server that, for example, a Contact
    who has a Boolean flag "isTutor" that was validated as not-null on the
    client would fail validation on the server .. where that validation
    found the value to be null.

    We previously had on the server prePersist methods that had things like:
    if (getIsTutor() == null) {
            setIsTutor(false);
    }

    I refactored these (after the jar update) to postAdd (when noticing
    that it wasn't working anymore .. and checked the mail archives for
    what Andrus had committed) ... and found that things weren't working
    either way until I rolled back the jar update.

    Perhaps you've some specific debugging code I can try to mix in with
    our classes that could provide more info?

    > public class ROPCallbacksTest extends RemoteCayenneCase {
    > public void testPostAddCallbacks() {
    > LifecycleCallbackRegistry registry = getDomain()
    > .getEntityResolver()
    > .getCallbackRegistry();
    >
    > registry.addListener(LifecycleEvent.POST_ADD, MtTable1.class,
    > this,
    > "postAddCallback");
    >
    > ObjectContext ropContext = createROPContext();
    > ClientMtTable1 a1 = ropContext.newObject(ClientMtTable1.class);
    > ropContext.commitChanges();
    > }
    >
    > public void postAddCallback(Object o) {
    > ((MtTable1) o).setGlobalAttribute1("POST_ADD");
    > }
    > }
    >
    > 2009/10/30 Andrey Razumovsky <razumovsky.andre..mail.com>
    >
    >> Actually, I won't be connected to the internet, so I will not
    >> commit until
    >> Monday anyways. So please go ahead
    >>
    >> 2009/10/30 Andrus Adamchik <andru..bjectstyle.org>
    >>
    >>>
    >>> On Oct 30, 2009, at 10:57 AM, Andrey Razumovsky wrote:
    >>>
    >>> This is not about callbacks on client-side - as far as I know, we
    >>> don't
    >>>> have
    >>>> callbacks on ROP.
    >>>>
    >>>
    >>> Ah great. I wasn't sure about the status of that.
    >>>
    >>>
    >>> If I understand correctly, "prePersist" isn't invoked for
    >>>> server-side temporary objects when committing from client.
    >>>> I'll try to do that on the weekend, but I'm not sure
    >>>>
    >>>
    >>> Let me know. I can take a look as well if needed.
    >>>
    >>> Andrus
    >>>
    >>>
    >>
    >>
    >> --
    >> Andrey
    >>
    >
    >
    >
    > --
    > Andrey

    with regards,

    --
    

    Lachlan Deck



    This archive was generated by hypermail 2.0.0 : Fri Oct 30 2009 - 17:22:18 EDT