Problems understanding delete behavior

From: Mark Evenson (evenso..anix.com)
Date: Tue Dec 09 2003 - 13:10:49 EST

  • Next message: Andrus Adamchik: "Re: Problems understanding delete behavior"

    We have run into some problems with deleting entities using cayenne-1.0.3
    using Tomcat and Struts. Essentially, unless we invalidate the session
    copy of DataContext explicitly, after deletion we still get objects
    back from the DataContext which no longer exist in the database.

    We are still trying to distill a test case down for public consumption, but
    in the meantime I have a small standalone example whose behavior could use
    some explaining.

    The attached schema describes the simple nested relationship:

            TestCategory +----<< TestGroup +----<< TestSubject

    The class TestDelete contains the methods:

            list()
                    select a TestCategory

                    use the getTestGroupArray() method to list all associated
                    TestGroup
            
            delete()
                    select a TestGroup for deletion

                    use the getTestSubjectArray() to delete all associated
                    TestSubject
            
                    delete the TestGroup

    the main() method invokes
            list()
            delete()
            list()

    On the second invocation of list(), the TestGroup that was deleted is still
    returned, although its state is marked as TRANSIENT. I would expect that
    this object would not be listed at all by in the getTestGroupArray(), as
    presumably "fresh" SQL is being executed by the QueryEngine (indeed the
    QueryLogger shows a PreparedStatement being fired).

    Is my code correct for performing deletion? Why is the deleted TestGroup
    being returned at all? Isn't this rather inconvient to have to check
    returned objects to see if their status is TRANSIENT or not? Do we have to
    explicity call both:

          group.removeFromTestSubjectArray(subject);
          dataContext.deleteObject(subject);

    or is only the second statement really necessary? (I would expect that
    Cayenne could take care of this).

    In our "real" code, we see the state of the deleted objects go from
    TRANSIENT to COMMITED again totally confuses us, but, again, we haven't
    been able to replicate this behavior in a standalone case.

    We are using cayenne-1.0.3 with Sybase ASE 12.5.1.

    Any clues would be most appreciated.

    -- 
    Mark Evenson <evenso..anix.com>
    

    "A screaming comes across the sky. It has happened before, but there is nothing to compare to it now."





    This archive was generated by hypermail 2.0.0 : Tue Dec 09 2003 - 13:20:25 EST