cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r586948 - in /cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc: EJBQLPathTranslator.java EJBQLUpdateItemTranslator.java JdbcEJBQLTranslatorFactory.java
Date Sun, 21 Oct 2007 20:03:55 GMT
Author: aadamchik
Date: Sun Oct 21 13:03:54 2007
New Revision: 586948

URL: http://svn.apache.org/viewvc?rev=586948&view=rev
Log:
making alias-free update syntax the default for all drivers

Modified:
    cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
    cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLUpdateItemTranslator.java
    cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JdbcEJBQLTranslatorFactory.java

Modified: cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java?rev=586948&r1=586947&r2=586948&view=diff
==============================================================================
--- cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
(original)
+++ cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLPathTranslator.java
Sun Oct 21 13:03:54 2007
@@ -59,10 +59,12 @@
     protected String joinMarker;
     private String fullPath;
     private EJBQLExpressionVisitor joinAppender;
+    private boolean usingAliases;
 
     EJBQLPathTranslator(EJBQLTranslationContext context) {
         super(true);
         this.context = context;
+        this.usingAliases = true;
     }
 
     protected abstract void appendMultiColumnPath(EJBQLMultiColumnOperand operand);
@@ -212,11 +214,17 @@
     protected void processTerminatingAttribute(ObjAttribute attribute) {
 
         DbEntity table = currentEntity.getDbEntity();
-        String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(
-                idPath,
-                table.getFullyQualifiedName());
-        context.append(' ').append(alias).append('.').append(
-                attribute.getDbAttributeName());
+
+        if (isUsingAliases()) {
+            String alias = this.lastAlias != null ? lastAlias : context.getTableAlias(
+                    idPath,
+                    table.getFullyQualifiedName());
+            context.append(' ').append(alias).append('.').append(
+                    attribute.getDbAttributeName());
+        }
+        else {
+            context.append(' ').append(attribute.getDbAttributeName());
+        }
     }
 
     private void processTerminatingRelationship(ObjRelationship relationship) {
@@ -240,7 +248,11 @@
 
             if (pks.size() == 1) {
                 DbAttribute pk = (DbAttribute) pks.get(0);
-                context.append(' ').append(alias).append('.').append(pk.getName());
+                context.append(' ');
+                if (isUsingAliases()) {
+                    context.append(alias).append('.');
+                }
+                context.append(pk.getName());
             }
             else {
                 throw new EJBQLException(
@@ -264,11 +276,11 @@
 
             if (joins.size() == 1) {
                 DbJoin join = (DbJoin) joins.get(0);
-                context
-                        .append(' ')
-                        .append(alias)
-                        .append('.')
-                        .append(join.getSourceName());
+                context.append(' ');
+                if (isUsingAliases()) {
+                    context.append(alias).append('.');
+                }
+                context.append(join.getSourceName());
             }
             else {
                 Map multiColumnMatch = new HashMap(joins.size() + 2);
@@ -276,7 +288,7 @@
                 Iterator it = joins.iterator();
                 while (it.hasNext()) {
                     DbJoin join = (DbJoin) it.next();
-                    String column = alias + "." + join.getSourceName();
+                    String column = isUsingAliases() ? alias + "." + join.getSourceName()
: join.getSourceName();
 
                     multiColumnMatch.put(join.getTargetName(), column);
                 }
@@ -286,5 +298,13 @@
                         multiColumnMatch));
             }
         }
+    }
+
+    public boolean isUsingAliases() {
+        return usingAliases;
+    }
+
+    public void setUsingAliases(boolean usingAliases) {
+        this.usingAliases = usingAliases;
     }
 }

Modified: cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLUpdateItemTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLUpdateItemTranslator.java?rev=586948&r1=586947&r2=586948&view=diff
==============================================================================
--- cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLUpdateItemTranslator.java
(original)
+++ cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/EJBQLUpdateItemTranslator.java
Sun Oct 21 13:03:54 2007
@@ -94,6 +94,10 @@
             }
         };
 
+
+        // some DB's do not support aliases in SET (Postgresql)
+        pathTranslator.setUsingAliases(false);
+
         expression.visit(pathTranslator);
         return false;
     }

Modified: cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JdbcEJBQLTranslatorFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JdbcEJBQLTranslatorFactory.java?rev=586948&r1=586947&r2=586948&view=diff
==============================================================================
--- cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JdbcEJBQLTranslatorFactory.java
(original)
+++ cayenne/main/tags/3.0M2/cayenne/framework/cayenne-jdk1.4-unpublished/src/main/java/org/apache/cayenne/access/jdbc/JdbcEJBQLTranslatorFactory.java
Sun Oct 21 13:03:54 2007
@@ -38,6 +38,7 @@
     }
 
     public EJBQLExpressionVisitor getUpdateTranslator(EJBQLTranslationContext context) {
+        context.setUsingAliases(false);
         return new EJBQLUpdateTranslator(context);
     }
 



Mime
View raw message