Re: weird problems with context

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jun 05 2007 - 07:29:27 EDT

  • Next message: Andrus Adamchik: "Re: SQLTemplate not faulting an object"

    This seems related to this thread started by Lachlan:

    http://objectstyle.org/cayenne/lists/cayenne-devel/2007/06/0027.html

    The use of a proxy context may confuse the issues. If you are aware
    of this behavior, it is usually easy to work around (by avoiding
    calls like "cat.getObjectContext().newObject(SomeEntity.class)"). We
    will try to fix it per CAY-797 though, by avoiding the use of proxy
    context for callbacks (no matter how much I like the separation of
    concerns and runtime flexibility provided by the proxy-based
    design :-)).

    Andrus

    On Jun 5, 2007, at 8:38 AM, Marcin Skladaniec wrote:

    > Hi,
    >
    > I would like to clarify, that the context are not equal, and it
    > does not matter if I choose to compare them by "equal()" or "==".
    >
    > I cant still get to the bottom of it, how it is possible, that if
    > both listeners (prePersist and postPersist) are registered
    > together, only one of them is fired when using
    > anObject.getObjectContext().newObject().
    >
    > Marcin
    >
    >
    > On 02/06/2007, at 11:43 AM, Marcin Skladaniec wrote:
    >
    >> Hi
    >> I'm having a strange problem. When executing this bit of code:
    >>
    >> List categories = aContext.performQuery(new SelectQuery
    >> (Category.class));
    >> if (categories.size() != 0) {
    >> for (int categoriesCount = 0; categoriesCount < categories.size
    >> (); categoriesCount++) {
    >> Category cat = (Category) categories.get(categoriesCount);
    >> logger.debug("context equal ? " + cat.getObjectContext().equals
    >> (aContext));
    >> }
    >> }
    >>
    >> the contexts are not equal, and I cant find the reason why !
    >>
    >> I found this problem, because the perPersist() callback is not
    >> fired when I do
    >> cat.getObjectContext().newObject(SomeEntity.class)
    >> but it is when
    >> aContext.newObject(SomeEntity.class)
    >> to add complexity, postPersist() and other callbacks are fired in
    >> both cases.
    >>
    >> Any clues ?
    >>
    >> Marcin
    >>
    >
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Tue Jun 05 2007 - 07:29:54 EDT