Re: Pre-insert callback?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Mar 18 2009 - 05:47:02 EDT

  • Next message: Andrey Razumovsky: "Re: ROP & Classics hierarchies union?"

    After the initial excitement about JPA callbacks, now I feel like they
    are not all that flexible (not in the context of Cayenne anyways). At
    this point I won't suggest deviating from the JPA spec... Unless we
    entertain the possibility to bag JPA as a goal completely, instead of
    saying "we'll give it another try after 3.0". But until we
    "officially" make any such decision, we are bound by the spec in some
    of the features.

    Andrus

    On Mar 6, 2009, at 10:38 PM, Kevin Menard wrote:
    > I think these callbacks are defined in the JPA spec. I had started
    > reading
    > it, hoping to get access to the JPA TCK, but other things happened
    > in my
    > life. I'd give JSR-220 a ponder.
    > I don't think anyone would object to adding new callback types, but
    > getting
    > rid of ones defined in the spec is obviously problematic.
    >
    > --
    > Kevin
    >
    >
    > On Fri, Mar 6, 2009 at 11:13 AM, Andrey Razumovsky <
    > razumovsky.andre..mail.com> wrote:
    >
    >> Hi,
    >>
    >> currently we have prePersist and postPersist callbacks, which are
    >> fired for
    >> new objects. But the problem is that 'prePersist' callback is
    >> called only
    >> when context.newObject() is invoked and the data object has no
    >> properties.
    >> So, since 'preUpdate'is only invoked at modified objects, there's no
    >> callback *just before* commit. the only way for me to intercept new
    >> objects
    >> is in "validateForInsert", but this is certainly ugly. Or maybe I'm
    >> just
    >> missing something?
    >> I suggest that at the minimum we add a new callback ("preInsert").
    >> to keep API understandable I find it reasonable to deprecate
    >> postPersist
    >> and rename it to postInsert.
    >>
    >> Thanks,
    >> Andrey
    >>



    This archive was generated by hypermail 2.0.0 : Wed Mar 18 2009 - 05:47:37 EDT