Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-797

Lifecycle callbacks *CallbackInterceptor concept introduces problems for testing equality of contexts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 3.0M2
    • Core Library
    • None
    • 3.0-prerelease svn 523667

    Description

      Say you create a callback intercepted context as described here (http://cayenne.apache.org/doc/lifecycle-callbacks.html), or as in my case created a subclass of ObjectContextCallbackInterceptor to wrap these concepts.

      ObjectContext myContext = new CallbackInterceptedContext();
      Object a = myContext.newObject(SomeClass.class);
      Object b = myContext.newObject(SomeClass.class);

      myContext.equals( a.getObjectContext() ); // false (unless I override equals to provide a better test)
      a.getObjectContext().equals( myContext ); // false
      a.getObjectContext() == myContext; // false
      a.getObjectContext().equals( b.getObjectContext() ); // true

      So this gets a little messy having to essentially test in the correct direction. Now, I understand why this occurs (because the CallbackIntercepting essentially provides a proxy context for the context it contains) but it seems to me that this leads to some difficulties like the above that could possibly be more easily overcome were both DataContext and CayenneContext to implement callback intercepting directly.

      Thoughts?

      Attachments

        Issue Links

          Activity

            People

              andrus Andrus Adamchik
              ldeck Lachlan Deck
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: