Author: aadamchik
Date: Wed Feb 10 22:06:13 2010
New Revision: 908670
URL: http://svn.apache.org/viewvc?rev=908670&view=rev
Log:
CAY-1378 Error unsetting to-many DataObject property
reverting CAY-1009 patch + some trivial method refactoring
Added:
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1378Test.java
Modified:
cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
Modified:
cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL:
http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=908670&r1=908669&r2=908670&view=diff
==============================================================================
---
cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
(original)
+++
cayenne/main/branches/STABLE-3.0/docs/doc/src/main/resources/RELEASE-NOTES.txt
Wed Feb 10 22:06:13 2010
@@ -14,6 +14,8 @@
Bug Fixes Since 3.0RC2:
+CAY-1378 Error unsetting to-many DataObject property
+ (this also reverts CAY-1009)
CAY-1379 Error resolving fault, no matching row exists in the database
CAY-1382 org.apache.cayenne.reflect.EnumConverter not handling null values for
ExtendedEnumerations
CAY-1383 unneeded target in modeler attributes inspection
Modified:
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL:
http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=908670&r1=908669&r2=908670&view=diff
==============================================================================
---
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
(original)
+++
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
Wed Feb 10 22:06:13 2010
@@ -163,6 +163,7 @@
* Returns a "complimentary" ObjRelationship going in the opposite
direction. Returns
* null if no such relationship is found.
*/
+ @Override
public ObjRelationship getReverseRelationship() {
// reverse the list
@@ -170,8 +171,8 @@
List<DbRelationship> reversed = new
ArrayList<DbRelationship>(relationships
.size());
- for (DbRelationship rel : relationships) {
- DbRelationship reverse = rel.getReverseRelationship();
+ for (DbRelationship relationship : relationships) {
+ DbRelationship reverse = relationship.getReverseRelationship();
if (reverse == null) {
return null;
}
@@ -183,15 +184,16 @@
if (target == null) {
return null;
}
+
+ Entity source = getSourceEntity();
- Iterator<?> it = target.getRelationships().iterator();
- while (it.hasNext()) {
- ObjRelationship rel = (ObjRelationship) it.next();
- if (target.isSubentityOf((ObjEntity) rel.getTargetEntity())) {
+ for (ObjRelationship relationship : target.getRelationships()) {
+
+ if (relationship.getTargetEntity() != source) {
continue;
}
- List<?> otherRels = rel.getDbRelationships();
+ List<?> otherRels = relationship.getDbRelationships();
if (reversed.size() != otherRels.size()) {
continue;
}
@@ -206,7 +208,7 @@
}
if (relsMatch) {
- return rel;
+ return relationship;
}
}
Added:
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1378Test.java
URL:
http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1378Test.java?rev=908670&view=auto
==============================================================================
---
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1378Test.java
(added)
+++
cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1378Test.java
Wed Feb 10 22:06:13 2010
@@ -0,0 +1,62 @@
+/*****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ ****************************************************************/
+package org.apache.cayenne.unit.jira;
+
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.testdo.inheritance_flat.Group;
+import org.apache.cayenne.testdo.inheritance_flat.User;
+import org.apache.cayenne.unit.AccessStack;
+import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.CayenneResources;
+
+public class CAY_1378Test extends CayenneCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deleteTestData();
+ }
+
+ @Override
+ protected AccessStack buildAccessStack() {
+ return
CayenneResources.getResources().getAccessStack("InheritanceFlatStack");
+ }
+
+ public void testFlattenedNullifyNullifyDeleteRules() throws Exception {
+
+ DataContext context = createDataContext();
+
+ User user = context.newObject(User.class);
+ user.setName("test_user");
+ Group group = context.newObject(Group.class);
+ group.setName("test_group");
+ group.addToGroupMembers(user);
+ context.commitChanges();
+
+ context.deleteObject(user);
+ assertTrue(group.getGroupMembers().isEmpty());
+
+ context.commitChanges();
+
+ // here Cayenne would throw per CAY-1378 on an attempt to delete a
previously
+ // related transient object
+ context.deleteObject(group);
+ context.commitChanges();
+ }
+}