Fwd: [JIRA] Created: (CAY-784) Deleting an object with a read-only flattened relationship fails

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri May 04 2007 - 08:10:15 EDT

  • Next message: Andrus Adamchik: "Re: Discussing 1.2.3 and 2.0.3 release"

    I am going to apply the fix suggested by Daniel (see the patch
    below). I haven't looked at this code in a while. Anybody can think
    of a reason why this would be a BAD idea to do it this way?

    As a side note the current logic (with or without the fix) in
    DataContextDeleteAction does look suspect in regards to the flattened
    relationships processing...

    Thanks
    Andrus

    Index: cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/
    DataContextDeleteAction.java
    ===================================================================
    --- cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/
    DataContextDeleteAction.java (revision 531846)
    +++ cayenne-java/src/cayenne/java/org/objectstyle/cayenne/access/
    DataContextDeleteAction.java (working copy)
    ..-163,7 +163,7 @@
                  ObjRelationship relationship = (ObjRelationship) it.next
    ();
                  boolean processFlattened = relationship.isFlattened()
    - && relationship.isToDependentEntity();
    + && relationship.isToDependentEntity() && !
    relationship.isReadOnly();
                  // first check for no action... bail out if no
    flattened processing is needed
                  if (relationship.getDeleteRule() ==
    DeleteRule.NO_ACTION && !processFlattened) {

    Begin forwarded message:
    > From: "Daniel Uribe (JIRA)" <de..ayenne.apache.org>
    > Date: May 3, 2007 1:04:48 AM GMT+03:00
    > To: cayenne-de..ncubator.apache.org
    > Subject: [JIRA] Created: (CAY-784) Deleting an object with a read-
    > only flattened relationship fails
    > Reply-To: de..ayenne.apache.org
    >
    > Deleting an object with a read-only flattened relationship fails
    > ----------------------------------------------------------------
    >
    > Key: CAY-784
    > URL: https://issues.apache.org/cayenne/browse/CAY-784
    > Project: Cayenne
    > Issue Type: Bug
    > Components: Cayenne Core Library
    > Affects Versions: 2.0 [STABLE]
    > Environment: Tomcat 5.5.17 under Windows XP SP 2
    > Reporter: Daniel Uribe
    > Assigned To: Andrus Adamchik
    > Priority: Critical
    >
    >
    > When commiting a delete for an object that has a read-only
    > flattened relationship with NO_ACTION as the delete rule, that
    > relationship still seems to be processed causing the following
    > exception to be thrown:
    >
    > org.apache.cayenne.CayenneRuntimeException:[v.2.0.2 January 14
    > 2007] Cannot unset the read-only flattened relationship
    > fullTextLanguagesArray
    > org.apache.cayenne.access.DataDomainIndirectDiffBuilder.arcDeleted
    > (DataDomainIndirectDiffBuilder.java:128)
    >
    >
    >
    > After doing some debugging, it seems that problem is coming from
    > the DataContextDeleteAction class, because it is setting the
    > processFlattened as true. It only takes a look at whether it is a
    > flattened relationship and if the relationship is to a dependent
    > entity, but doesn't look at whether it is read only or not. This
    > causes the objectStore.recordArcDeleted() to be called for the
    > object related through this flattened read-only relationship.
    >
    > In our case, this flattened relationship (fullTextLanguagesArray)
    > has a relationship path that takes it through 4 relationships, so
    > it's definitely a read-only flattened relationship. I can also say
    > this for sure, because the DataDomainIndirectDiffBuilder.arcDeleted
    > checks whether the relationship is flattened and read-only, and
    > that's when the exception is thrown.
    >
    > I would think that changing:
    >
    > boolean processFlattened = relationship.isFlattened() &&
    > relationship.isToDependentEntity();
    >
    > to
    >
    > boolean processFlattened = relationship.isFlattened() &&
    > relationship.isToDependentEntity() && !relationship.isReadOnly();
    >
    > would fix the issue.
    >
    > Please let me know if you need any details. I would be really
    > interested to have this fixed in a patch release of 2.0 soon, since
    > it is preventing us from using one part of our system.
    >
    > --
    > 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 May 04 2007 - 08:10:59 EDT