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

Deleting an object with a read-only flattened relationship fails

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.0 branch
    • 3.0M1
    • Core Library
    • None
    • Tomcat 5.5.17 under Windows XP SP 2

    Description

      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.

      Attachments

        Activity

          People

            andrus Andrus Adamchik
            duribe Daniel Uribe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: