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

Potential bug deleting uncommited objects from a nested DataContext

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0
    • 3.0M2
    • Core Library
    • None
    • OS X, Java 1.5

    Description

      Quoting from e-mail list:

      DataContext childContext = parentContext.createChildDataContext();

      I have a Master and 3 Details (1-to-many) in the parent DC (in a
      committed state), and pull the Master into the nested DC using
      localObject(). If I then do the following:

      Master childMaster = (Master)
      childContext.localObject(parentMaster.getObjectId(), null);

      Detail d = (Detail) childContext.newObject(Detail.class);
      d.setXXXXXXXX(...); // do sets
      childMaster.addToDetails(d);

      childContext.commitChangesToParent();

      childContext.deleteObject(d);
      childMaster.removeFromDetails(d);
      childContext.commitChangesToParent();

      I get an exception on the last commitChangesToParent():

      Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
      [v.3.0M1 Jul 16 2007 22:25:33] Can't build a query for temporary id:
      <ObjectId:Detail, TEMP:000004B078EB2838>

      Is this to be expected? If I change commitChangesToParent() to
      commitChanges() it works ...

      See attached project for full code and test harness. To run, you'll need to adjust the DB connection information and generate the schema.

      Attachments

        1. ndc.tar.gz
          6 kB
          Michael Gentry

        Activity

          People

            andrus Andrus Adamchik
            blacknext Michael Gentry
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: