cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r551286 - in /cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src: main/java/org/apache/cayenne/access/jdbc/ test/java/org/apache/cayenne/access/jdbc/
Date Wed, 27 Jun 2007 19:30:50 GMT
Author: aadamchik
Date: Wed Jun 27 12:30:49 2007
New Revision: 551286

URL: http://svn.apache.org/viewvc?view=rev&rev=551286
Log:
CAY-813 SQLTemplate improvement: #column directive
(a temporary fix for EJBQL that involves an unofficial 5th parameter to #result direcive;
will switch to #column directive once that becomes available)

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLSelectColumnsTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ResultDirective.java
    cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java?view=diff&rev=551286&r1=551285&r2=551286
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLIdentifierColumnsTranslator.java
Wed Jun 27 12:30:49 2007
@@ -155,8 +155,11 @@
                     javaType = TypesMapping.getJavaBySqlType(column.getType());
                 }
 
+                // 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("')");
+                        column.getName()).append("' '").append(column.getName()).append(
+                        "' " + column.getType()).append(")");
             }
         }
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLSelectColumnsTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLSelectColumnsTranslator.java?view=diff&rev=551286&r1=551285&r2=551286
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLSelectColumnsTranslator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLSelectColumnsTranslator.java
Wed Jun 27 12:30:49 2007
@@ -22,6 +22,7 @@
 import org.apache.cayenne.ejbql.EJBQLException;
 import org.apache.cayenne.ejbql.EJBQLExpression;
 import org.apache.cayenne.ejbql.parser.EJBQLPath;
+import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjAttribute;
 
@@ -55,8 +56,7 @@
 
     public boolean visitPath(EJBQLPath expression, int finishedChildIndex) {
 
-        EJBQLPathTranslator pathTranslator = new EJBQLPathTranslator(
-                context) {
+        EJBQLPathTranslator pathTranslator = new EJBQLPathTranslator(context) {
 
             protected void appendMultiColumnPath(EJBQLMultiColumnOperand operand) {
                 throw new EJBQLException("Can't use multi-column paths in column clause");
@@ -67,10 +67,24 @@
                 String alias = this.lastAlias != null ? lastAlias : context
                         .getTableAlias(idPath, table.getFullyQualifiedName());
 
-                context.append(" #result('").append(alias).append('.').append(
-                        attribute.getDbAttributeName()).append("' '").append(
-                        attribute.getType()).append("' '").append(
-                        context.nextColumnAlias()).append("')");
+                DbAttribute dbAttribute = (DbAttribute) attribute.getDbAttribute();
+
+                // TODO: andrus 6/27/2007 - the last parameter is an unofficial "jdbcType"
+                // pending CAY-813 implementation, switch to #column directive
+                String columnAlias = context.nextColumnAlias();
+                context
+                        .append(" #result('")
+                        .append(alias)
+                        .append('.')
+                        .append(dbAttribute.getName())
+                        .append("' '")
+                        .append(attribute.getType())
+                        .append("' '")
+                        .append(columnAlias)
+                        .append("' '")
+                        .append(columnAlias)
+                        .append("' " + dbAttribute.getType())
+                        .append(")");
             }
         };
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ResultDirective.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ResultDirective.java?view=diff&rev=551286&r1=551285&r2=551286
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ResultDirective.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ResultDirective.java
Wed Jun 27 12:30:49 2007
@@ -43,10 +43,10 @@
  * possible invocation formats inside the template:
  * 
  * <pre>
- *      #result(column_name) - e.g. #result('ARTIST_ID')
- *      #result(column_name java_type) - e.g. #result('ARTIST_ID' 'String')
- *      #result(column_name java_type column_alias) - e.g. #result('ARTIST_ID' 'String' 'ID')
- *      #result(column_name java_type column_alias data_row_key) - e.g. #result('ARTIST_ID'
'String' 'ID' 'toArtist.ID')
+ *       #result(column_name) - e.g. #result('ARTIST_ID')
+ *       #result(column_name java_type) - e.g. #result('ARTIST_ID' 'String')
+ *       #result(column_name java_type column_alias) - e.g. #result('ARTIST_ID' 'String'
'ID')
+ *       #result(column_name java_type column_alias data_row_key) - e.g. #result('ARTIST_ID'
'String' 'ID' 'toArtist.ID')
  * </pre>
  * 
  * <p>
@@ -132,6 +132,13 @@
         String type = getChildAsString(context, node, 1);
         if (type != null) {
             columnDescriptor.setJavaClass(guessType(type.toString()));
+        }
+
+        // TODO: andrus 6/27/2007 - this is an unofficial jdbcType parameter that is added
+        // temporarily pending CAY-813 implementation for the sake of EJBQL query...
+        Object jdbcType = getChild(context, node, 4);
+        if(jdbcType instanceof Number) {
+            columnDescriptor.setJdbcType(((Number) jdbcType).intValue());
         }
 
         writer.write(column);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java?view=diff&rev=551286&r1=551285&r2=551286
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.4-unpublished/src/test/java/org/apache/cayenne/access/jdbc/EJBQLSelectTranslatorTest.java
Wed Jun 27 12:30:49 2007
@@ -288,8 +288,8 @@
         String sql = query.getDefaultTemplate();
 
         assertTrue(sql, sql.startsWith("SELECT "
-                + "#result('t0.ESTIMATED_PRICE' 'java.math.BigDecimal' 'sc0'), "
-                + "#result('t1.ARTIST_NAME' 'java.lang.String' 'sc1') FROM"));
+                + "#result('t0.ESTIMATED_PRICE' 'java.math.BigDecimal' 'sc0' 'sc0' 3), "
+                + "#result('t1.ARTIST_NAME' 'java.lang.String' 'sc1' 'sc1' 1) FROM"));
     }
 
     private int countDelimiters(String string, String delim, int fromIndex) {



Mime
View raw message