cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r671541 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/map/ test/java/org/apache/cayenne/
Date Wed, 25 Jun 2008 13:04:54 GMT
Author: aadamchik
Date: Wed Jun 25 06:04:54 2008
New Revision: 671541

URL: http://svn.apache.org/viewvc?rev=671541&view=rev
Log:
CAY-1081 DataObjectUtils.objectForPk broken in ROP

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextDataObjectUtilsTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjEntity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjEntity.java?rev=671541&r1=671540&r2=671541&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjEntity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ClientObjEntity.java
Wed Jun 25 06:04:54 2008
@@ -43,7 +43,7 @@
     public Collection<String> getPrimaryKeyNames() {
         Collection<String> names = new ArrayList<String>(primaryKeys.size());
         for (ObjAttribute attribute : primaryKeys) {
-            names.add(attribute.getName());
+            names.add(attribute.getDbAttributePath());
         }
         return Collections.unmodifiableCollection(names);
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java?rev=671541&r1=671540&r2=671541&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjEntity.java
Wed Jun 25 06:04:54 2008
@@ -793,6 +793,9 @@
     }
 
     /**
+     * Returns the names of DbAtributes that comprise the primary key of the parent
+     * DbEntity.
+     * 
      * @since 3.0
      */
     public Collection<String> getPrimaryKeyNames() {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextDataObjectUtilsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextDataObjectUtilsTest.java?rev=671541&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextDataObjectUtilsTest.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CayenneContextDataObjectUtilsTest.java
Wed Jun 25 06:04:54 2008
@@ -0,0 +1,61 @@
+/*****************************************************************
+ *   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;
+
+import org.apache.cayenne.access.ClientServerChannel;
+import org.apache.cayenne.query.SQLTemplate;
+import org.apache.cayenne.remote.ClientChannel;
+import org.apache.cayenne.remote.service.LocalConnection;
+import org.apache.cayenne.testdo.mt.ClientMtTable1;
+import org.apache.cayenne.testdo.mt.MtTable1;
+import org.apache.cayenne.unit.AccessStack;
+import org.apache.cayenne.unit.CayenneCase;
+import org.apache.cayenne.unit.CayenneResources;
+
+public class CayenneContextDataObjectUtilsTest extends CayenneCase {
+
+    @Override
+    protected AccessStack buildAccessStack() {
+        return CayenneResources.getResources().getAccessStack(MULTI_TIER_ACCESS_STACK);
+    }
+
+    private CayenneContext createClientContext() {
+        ClientServerChannel serverChannel = new ClientServerChannel(getDomain());
+        LocalConnection connection = new LocalConnection(serverChannel);
+        ClientChannel clientChannel = new ClientChannel(connection);
+        return new CayenneContext(clientChannel);
+    }
+
+    public void testObjectForPK() throws Exception {
+
+        deleteTestData();
+
+        CayenneContext context = createClientContext();
+
+        context.performGenericQuery(new SQLTemplate(
+                MtTable1.class,
+                "insert into MT_TABLE1 "
+                        + "(TABLE1_ID, GLOBAL_ATTRIBUTE1, SERVER_ATTRIBUTE1) "
+                        + "values (1, 'g1', 's1')"));
+
+        ClientMtTable1 o = DataObjectUtils.objectForPK(context, ClientMtTable1.class, 1);
+        assertNotNull(o);
+        assertEquals("g1", o.getGlobalAttribute1());
+    }
+}



Mime
View raw message