Re: [jira] Created: (CAY-1109) Non-physical delete (through update) does not work properly

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Sep 19 2008 - 09:22:38 EDT

  • Next message: Ari Maniatis (JIRA): "[jira] Closed: (CAY-643) Paginates queries are failing"

    I think Ari and Marcin ran into a similar problem (wonder if there is
    a duplicate Jira?). I guess there are few things we can do here:

    1. When resolving to-one relationships, do not create eager faults for
    the target entity if there is a qualifier on that entity (I think this
    may actually be working already).

    2. When an object is updated, we may use our new callback mechanism to
    run an internal callback to check that the object in question still
    matches the qualifier. If it doesn't, we need to do the following:
    Unregistering it iand turning it into a TRANSIENT object; run
    something similar to the delete rules processor to remove it from
    already resolved relationships (and actually follow the delete rules
    in doing that).

    Andrus

    On Sep 19, 2008, at 4:12 PM, Andrey Razumovsky (JIRA) wrote:

    > Non-physical delete (through update) does not work properly
    > -----------------------------------------------------------
    >
    > Key: CAY-1109
    > URL: https://issues.apache.org/cayenne/browse/CAY-1109
    > Project: Cayenne
    > Issue Type: Bug
    > Components: Cayenne Core Library
    > Affects Versions: 3.0
    > Reporter: Andrey Razumovsky
    > Assignee: Andrus Adamchik
    > Fix For: 3.0
    > Attachments: test-CAY-1109.txt
    >
    > I've got reasons to keep all records in database, even those user
    > had deleted. As a solution, I have a field called "deleted" which is
    > 0 by default and 1 if user had removed the data. To show only object
    > with 'deleted = 0' I add this qualifier to all objEntities. Finally,
    > I call setDeleted('1') instead of context.deleteObject()
    >
    > The problem is that after I invoke setDeleted("1") and commit, part
    > of Cayenne thinks that the object is deleted (and I'd agree with it)
    > while another part thinks it is not. Personally I think that setting
    > qualifier means that I cannot have registered objects that do not
    > match this qualifier.
    >
    > I've uploaded a test which shows that other side of relationships
    > with such objects is not updated properly. This test should succeed.
    > Even worse, sometimes (I failed to create a test by now) I get this
    > unfamous exception:
    >
    > org.apache.cayenne.FaultFailureException: [v.3.0M4 May 18 2008
    > 16:32:02]
    > Error resolving fault, no matching row exists in the database for
    > ObjectId:
    > <ObjectId:Apkforecast, apkforecastid=3>
    >
    > at org.apache.cayenne.BaseContext.prepareForAccess(BaseContext.java:
    > 100)
    > at com.nic.rainbow.data.auto._Apkforecast.getDate(_Apkforecast.java:
    > 29)
    >
    >
    > My suggestion is that we check declared qualifier after CDO update,
    > and if it does not match, unregister object and process delete rules.
    >
    > --
    > This message is automatically generated by JIRA.
    > -
    > You can reply to this email to add a comment to the issue online.
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Sep 19 2008 - 09:23:10 EDT