cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r609170 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
Date Sat, 05 Jan 2008 16:32:13 GMT
Author: aadamchik
Date: Sat Jan  5 08:32:12 2008
New Revision: 609170

URL: http://svn.apache.org/viewvc?rev=609170&view=rev
Log:
CAY-948 Implement flattened attributes in Cayenne
(EJBQL DataRow key naming consistent with SelectQuery DataRow)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java?rev=609170&r1=609169&r2=609170&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
Sat Jan  5 08:32:12 2008
@@ -94,7 +94,7 @@
                         lhsId = rhsId;
                     }
                     else if (pathPart instanceof DbAttribute) {
-                        appendColumn(idVar, (DbAttribute) pathPart, oa.getType());
+                        appendColumn(idVar, oa, (DbAttribute) pathPart, oa.getType());
                     }
                 }
                 return true;
@@ -116,7 +116,7 @@
 
                 for (DbJoin join : dbRel.getJoins()) {
                     DbAttribute src = join.getSource();
-                    appendColumn(idVar, src);
+                    appendColumn(idVar, null, src);
                 }
             }
         };
@@ -129,20 +129,30 @@
 
         DbEntity table = descriptor.getEntity().getDbEntity();
         for (DbAttribute pk : table.getPrimaryKeys()) {
-            appendColumn(idVar, pk);
+            appendColumn(idVar, null, pk);
         }
 
         return false;
     }
 
-    private void appendColumn(String identifier, DbAttribute column) {
-        appendColumn(identifier, column, null);
+    private void appendColumn(
+            String identifier,
+            ObjAttribute objectAttribute,
+            DbAttribute column) {
+        appendColumn(identifier, objectAttribute, column, null);
     }
 
-    private void appendColumn(String identifier, DbAttribute column, String javaType) {
+    private void appendColumn(
+            String identifier,
+            ObjAttribute objectAttribute,
+            DbAttribute column,
+            String javaType) {
+
         DbEntity table = (DbEntity) column.getEntity();
         String alias = context.getTableAlias(identifier, table.getFullyQualifiedName());
         String columnName = alias + "." + column.getName();
+        String columnLabel = objectAttribute != null ? objectAttribute
+                .getDbAttributePath() : column.getName();
 
         Set<String> columns = getColumns();
 
@@ -164,7 +174,7 @@
                 // TODO: andrus 6/27/2007 - the last parameter is an unofficial "jdbcType"
                 // pending CAY-813 implementation, switch to #column directive
                 context.append("' '").append(javaType).append("' '").append(
-                        column.getName()).append("' '").append(column.getName()).append(
+                        column.getName()).append("' '").append(columnLabel).append(
                         "' " + column.getType()).append(")");
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java?rev=609170&r1=609169&r2=609170&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextFlattenedAttributesTest.java
Sat Jan  5 08:32:12 2008
@@ -29,6 +29,7 @@
 import org.apache.art.Artist;
 import org.apache.art.CompoundPainting;
 import org.apache.cayenne.DataObjectUtils;
+import org.apache.cayenne.PersistenceState;
 import org.apache.cayenne.exp.ExpressionFactory;
 import org.apache.cayenne.query.EJBQLQuery;
 import org.apache.cayenne.query.SelectQuery;
@@ -159,6 +160,7 @@
 
         for (Iterator<?> i = objects.iterator(); i.hasNext();) {
             CompoundPainting painting = (CompoundPainting) i.next();
+            assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
             Number id = (Number) painting
                     .getObjectId()
                     .getIdSnapshot()
@@ -195,7 +197,7 @@
         Iterator<?> i = objects.iterator();
         while (i.hasNext()) {
             CompoundPainting painting = (CompoundPainting) i.next();
-            // assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
+            assertEquals(PersistenceState.COMMITTED, painting.getPersistenceState());
         }
     }
 



Mime
View raw message