You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by to...@apache.org on 2007/06/17 22:58:03 UTC
svn commit: r548110 - in
/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src:
main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
test/java/org/apache/cayenne/unit/jira/CAY_788Test.java
Author: torehalset
Date: Sun Jun 17 13:58:02 2007
New Revision: 548110
URL: http://svn.apache.org/viewvc?view=rev&rev=548110
Log:
CAY-788: prefetch can set state to modified
Added:
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_788Test.java
Modified:
cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java?view=diff&rev=548110&r1=548109&r2=548110
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/PrefetchProcessorNode.java Sun Jun 17 13:58:02 2007
@@ -86,9 +86,9 @@
if (parent != null) {
// if a relationship is to-one (i.e. flattened to-one), can connect right
- // away....
+ // away.... write directly to prevent changing persistence state.
if (incoming instanceof ToOneProperty) {
- incoming.writeProperty(parent, null, object);
+ incoming.writePropertyDirectly(parent, null, object);
}
else {
Added: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_788Test.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_788Test.java?view=auto&rev=548110
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_788Test.java (added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_788Test.java Sun Jun 17 13:58:02 2007
@@ -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 java.util.Iterator;
+import java.util.List;
+
+import org.apache.art.Painting;
+import org.apache.art.PaintingInfo;
+import org.apache.cayenne.PersistenceState;
+import org.apache.cayenne.access.DataContext;
+import org.apache.cayenne.query.SelectQuery;
+import org.apache.cayenne.query.SelectQueryBase;
+
+public class CAY_788Test extends SelectQueryBase {
+
+ public void testPrefetchToOne() {
+ DataContext ctxt = createDataContext();
+ SelectQuery query = new SelectQuery(Painting.class);
+ query.addPrefetch(Painting.TO_PAINTING_INFO_PROPERTY);
+ List daos = ctxt.performQuery(query);
+ assertTrue(!daos.isEmpty());
+ for (Iterator it = daos.iterator(); it.hasNext();) {
+ Painting p = (Painting) it.next();
+ PaintingInfo pi = p.getToPaintingInfo();
+ assertEquals("persistence state", PersistenceState.COMMITTED, p
+ .getPersistenceState());
+ assertEquals("persistence state", PersistenceState.COMMITTED, pi
+ .getPersistenceState());
+ }
+ }
+
+ protected void populateTables() throws Exception {
+ DataContext ctxt = createDataContext();
+ for (int i = 0; i < 10; i++) {
+ Painting p = (Painting) ctxt.newObject(Painting.class);
+ p.setPaintingTitle("Painting title #" + i);
+ p.setPaintingDescription("Painting desc #" + i);
+ PaintingInfo pi = (PaintingInfo) ctxt.newObject(PaintingInfo.class);
+ pi.setTextReview("Review #" + i);
+ p.setToPaintingInfo(pi);
+ }
+ ctxt.commitChanges();
+ }
+
+}