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 : Wed May 02 2007 - 18:05:19 EDT