cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r740672 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/jdbc/ main/java/org/apache/cayenne/access/trans/ main/java/org/apache/cayenne/dba/ main/java/org/apache/cayenne/dba/db2/ main/jav...
Date Wed, 04 Feb 2009 10:19:20 GMT
Author: aadamchik
Date: Wed Feb  4 10:19:19 2009
New Revision: 740672

URL: http://svn.apache.org/viewvc?rev=740672&view=rev
Log:
CAY-289 Implement Quoting of identifiers

patch by Olga Tkachova for insert/delete/update queries; also some rework of select

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/BatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DbAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/BatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ColumnDescriptor.java Wed Feb  4 10:19:19 2009
@@ -23,6 +23,7 @@
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.ObjAttribute;
@@ -198,9 +199,9 @@
         return (namePrefix != null) ? namePrefix + '.' + name : name;
     }
     
-    public String getQualifiedColumnNameWithQuoteSqlIdentifiers(String charStart, String charEnd) {
-        String nameWithQuoteSqlIdentifiers = charStart + name + charEnd;
-        return (namePrefix != null) ? charStart + namePrefix + charEnd + '.' +
+    public String getQualifiedColumnNameWithQuoteSqlIdentifiers(QuotingStrategy strategy) {
+        String nameWithQuoteSqlIdentifiers = strategy.quoteString( name );
+        return (namePrefix != null) ? strategy.quoteString( namePrefix ) + '.' +
                 nameWithQuoteSqlIdentifiers: nameWithQuoteSqlIdentifiers;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/BatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/BatchQueryBuilder.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/BatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/BatchQueryBuilder.java Wed Feb  4 10:19:19 2009
@@ -19,6 +19,7 @@
 
 package org.apache.cayenne.access.trans;
 
+import java.io.IOException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.sql.Types;
@@ -26,12 +27,12 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.query.BatchQuery;
 
 /**
  * Superclass of batch query translators.
- * 
  */
 
 public abstract class BatchQueryBuilder {
@@ -48,8 +49,10 @@
 
     /**
      * Translates BatchQuery into an SQL string formatted to use in a PreparedStatement.
+     * 
+     * @throws IOException
      */
-    public abstract String createSqlString(BatchQuery batch);
+    public abstract String createSqlString(BatchQuery batch) throws IOException;
 
     /**
      * Appends the name of the column to the query buffer. Subclasses use this method to
@@ -63,8 +66,17 @@
         if (trim) {
             buf.append(trimFunction).append('(');
         }
+        boolean status;
+        if (dbAttribute.getEntity().getDataMap() != null
+                && dbAttribute.getEntity().getDataMap().isQuotingSQLIdentifiers()) {
+            status = true;
+        }
+        else {
+            status = false;
+        }
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
 
-        buf.append(dbAttribute.getName());
+        buf.append(strategy.quoteString(dbAttribute.getName()));
 
         if (trim) {
             buf.append(')');
@@ -121,4 +133,5 @@
         }
         return values;
     }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilder.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilder.java Wed Feb  4 10:19:19 2009
@@ -19,18 +19,19 @@
 
 package org.apache.cayenne.access.trans;
 
+import java.io.IOException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.Iterator;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.query.BatchQuery;
 import org.apache.cayenne.query.DeleteBatchQuery;
 
 /**
  * Translator for delete BatchQueries. Creates parametrized DELETE SQL statements.
- * 
  */
 
 public class DeleteBatchQueryBuilder extends BatchQueryBuilder {
@@ -40,12 +41,21 @@
     }
 
     @Override
-    public String createSqlString(BatchQuery batch) {
+    public String createSqlString(BatchQuery batch) throws IOException {
+
         DeleteBatchQuery deleteBatch = (DeleteBatchQuery) batch;
-        String table = batch.getDbEntity().getFullyQualifiedName();
 
+        boolean status;
+        if(batch.getDbEntity().getDataMap()!=null && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
+       
         StringBuffer query = new StringBuffer("DELETE FROM ");
-        query.append(table).append(" WHERE ");
+        query.append(strategy.quoteFullyQualifiedName(batch.getDbEntity()));
+        query.append(" WHERE ");
 
         Iterator<DbAttribute> i = deleteBatch.getQualifierAttributes().iterator();
         while (i.hasNext()) {
@@ -89,4 +99,5 @@
                     attribute.getScale());
         }
     }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilder.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/InsertBatchQueryBuilder.java Wed Feb  4 10:19:19 2009
@@ -17,21 +17,21 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access.trans;
 
+import java.io.IOException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.query.BatchQuery;
 
 /**
  * Translator of InsertBatchQueries.
- * 
  */
 public class InsertBatchQueryBuilder extends BatchQueryBuilder {
 
@@ -85,12 +85,20 @@
     }
 
     @Override
-    public String createSqlString(BatchQuery batch) {
-        String table = batch.getDbEntity().getFullyQualifiedName();
+    public String createSqlString(BatchQuery batch) throws IOException {
+
         List<DbAttribute> dbAttributes = batch.getDbAttributes();
+        boolean status;
+        if(batch.getDbEntity().getDataMap()!=null && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
 
         StringBuilder query = new StringBuilder("INSERT INTO ");
-        query.append(table).append(" (");
+        query.append(strategy.quoteFullyQualifiedName(batch.getDbEntity()));
+        query.append(" (");
 
         int columnCount = 0;
         for (DbAttribute attribute : dbAttributes) {
@@ -105,7 +113,7 @@
                 if (columnCount > 0) {
                     query.append(", ");
                 }
-                query.append(attribute.getName());
+                query.append(strategy.quoteString(attribute.getName()));
                 columnCount++;
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java Wed Feb  4 10:19:19 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
@@ -38,9 +39,8 @@
 public class JoinStack {
 
     protected JoinTreeNode rootNode;
-    protected JoinTreeNode topNode;    
-    private String identifiersStartQuote;
-    private String identifiersEndQuote;
+    protected JoinTreeNode topNode; 
+    private QuotingStrategy strategy;
 
     private int aliasCounter;
     
@@ -57,14 +57,14 @@
     protected JoinStack(DbAdapter dbAdapter, DataMap dataMap) {
         this.rootNode = new JoinTreeNode(this);
         this.rootNode.setTargetTableAlias(newAlias());
-        
-        if(dataMap.isQuotingSQLIdentifiers()){
-            this.identifiersStartQuote = dbAdapter.getIdentifiersStartQuote();
-            this.identifiersEndQuote = dbAdapter.getIdentifiersEndQuote();
+        boolean status;
+        if(dataMap!=null && dataMap.isQuotingSQLIdentifiers()){ 
+            status= true;
         } else {
-            this.identifiersStartQuote = "";
-            this.identifiersEndQuote = "";
+            status = false;
         }
+        strategy =  dbAdapter.getQuotingStrategy(status);
+  
         resetStack();
     }
     
@@ -87,13 +87,14 @@
     }
     
     void appendRootWithQuoteSqlIdentifiers(Appendable out, DbEntity rootEntity) throws IOException {
+        
         if(rootEntity.getSchema() != null) { 
-            nameWithQuoteSqlIdentifiers(rootEntity.getSchema(),out);
+            out.append(strategy.quoteString(rootEntity.getSchema()));
             out.append(".");
         }
-        nameWithQuoteSqlIdentifiers(rootEntity.getName(),out);
+        out.append(strategy.quoteString(rootEntity.getName()));
         out.append(' ');
-        nameWithQuoteSqlIdentifiers(rootNode.getTargetTableAlias(),out);       
+        out.append(strategy.quoteString(rootNode.getTargetTableAlias()));       
     }
 
     /**
@@ -131,13 +132,13 @@
         
         if(targetEntity.getSchema()!= null){
             
-            nameWithQuoteSqlIdentifiers(targetEntity.getSchema(),out);
+            out.append(strategy.quoteString(targetEntity.getSchema()));
             out.append(".");
         }
-        nameWithQuoteSqlIdentifiers(targetEntity.getName(), out);
+        out.append(strategy.quoteString(targetEntity.getName()));
  
         out.append(' ');
-        nameWithQuoteSqlIdentifiers(targetAlias, out);
+        out.append(strategy.quoteString(targetAlias));
         out.append(" ON (");
 
         List<DbJoin> joins = relationship.getJoins();
@@ -148,13 +149,13 @@
                 out.append(" AND ");
             }            
             
-            nameWithQuoteSqlIdentifiers(srcAlias, out);
+            out.append(strategy.quoteString(srcAlias));
             out.append('.');
-            nameWithQuoteSqlIdentifiers(join.getSourceName(), out);
+            out.append(strategy.quoteString(join.getSourceName()));
             out.append(" = ");
-            nameWithQuoteSqlIdentifiers(targetAlias, out);
+            out.append(strategy.quoteString(targetAlias));
             out.append('.');
-            nameWithQuoteSqlIdentifiers(join.getTargetName(), out);
+            out.append(strategy.quoteString(join.getTargetName()));
         }
 
         out.append(')');
@@ -191,7 +192,4 @@
         return "t" + aliasCounter++;
     }
     
-    protected void nameWithQuoteSqlIdentifiers(String name, Appendable out) throws IOException{
-        out.append(identifiersStartQuote).append(name).append(identifiersEndQuote);        
-    }  
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/QueryAssemblerHelper.java Wed Feb  4 10:19:19 2009
@@ -28,6 +28,7 @@
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.Persistent;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.parser.SimpleNode;
 import org.apache.cayenne.map.DbAttribute;
@@ -48,8 +49,7 @@
 
     protected QueryAssembler queryAssembler;
     protected Appendable out;
-    private String identifiersStartQuote;
-    private String identifiersEndQuote;
+    protected QuotingStrategy strategy;
 
     /**
      * Creates QueryAssemblerHelper initializing with parent {@link QueryAssembler} and
@@ -57,14 +57,13 @@
      */
     public QueryAssemblerHelper(QueryAssembler queryAssembler) {
         this.queryAssembler = queryAssembler;
-        
-        if(queryAssembler.getQueryMetadata().getDataMap()!=null && queryAssembler.getQueryMetadata().getDataMap().isQuotingSQLIdentifiers()){
-            identifiersStartQuote = queryAssembler.getAdapter().getIdentifiersStartQuote();
-            identifiersEndQuote  = queryAssembler.getAdapter().getIdentifiersEndQuote();
+        boolean status;
+        if(queryAssembler.getQueryMetadata().getDataMap()!=null && queryAssembler.getQueryMetadata().getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
         } else {
-            identifiersStartQuote = "";
-            identifiersEndQuote = "";
+            status = false;
         }
+        strategy =   queryAssembler.getAdapter().getQuotingStrategy(status);
     }
 
     public ObjEntity getObjEntity() {
@@ -249,11 +248,12 @@
         String alias =  (queryAssembler.supportsTableAliases()) ? queryAssembler
                 .getCurrentAlias() : null;
       
-            if(alias != null){        
-                out.append(identifiersStartQuote).append(alias).append(identifiersEndQuote);
+            if(alias != null){
+                
+                out.append(strategy.quoteString(alias));
                 out.append(".");
             }
-            out.append(identifiersStartQuote).append(dbAttr.getName()).append(identifiersEndQuote);                     
+            out.append(strategy.quoteString(dbAttr.getName()));                     
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/SelectTranslator.java Wed Feb  4 10:19:19 2009
@@ -31,6 +31,7 @@
 
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
@@ -59,9 +60,6 @@
  */
 public class SelectTranslator extends QueryAssembler {
     
-    private String identifiersStartQuote;
-    private String identifiersEndQuote;
-    
     protected static final int[] UNSUPPORTED_DISTINCT_TYPES = new int[] {
             Types.BLOB, Types.CLOB, Types.LONGVARBINARY, Types.LONGVARCHAR
     };
@@ -102,14 +100,14 @@
     public String createSqlString() throws Exception {
         
         joinStack = createJoinStack();
-        
-        if(queryMetadata.getDataMap().isQuotingSQLIdentifiers()){
-            this.identifiersStartQuote = getAdapter().getIdentifiersStartQuote();
-            this.identifiersEndQuote = getAdapter().getIdentifiersEndQuote();
+        boolean status;
+        if(queryMetadata.getDataMap()!=null && queryMetadata.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
         } else {
-            this.identifiersStartQuote = "";
-            this.identifiersEndQuote = "";
+            status = false;
         }
+
+        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
         forcingDistinct = false;
        
         // build column list
@@ -148,7 +146,7 @@
         List<String> selectColumnExpList = new ArrayList<String>();
         for (ColumnDescriptor column : resultColumns) {
             selectColumnExpList.add(
-                        column.getQualifiedColumnNameWithQuoteSqlIdentifiers(identifiersStartQuote, identifiersEndQuote));
+                        column.getQualifiedColumnNameWithQuoteSqlIdentifiers(strategy));
         }
 
         // append any column expressions used in the order by if this query

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilder.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilder.java Wed Feb  4 10:19:19 2009
@@ -17,22 +17,22 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access.trans;
 
+import java.io.IOException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.cayenne.dba.DbAdapter;
+import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.query.BatchQuery;
 import org.apache.cayenne.query.UpdateBatchQuery;
 
 /**
  * A translator for UpdateBatchQueries that produces parameterized SQL.
- * 
  */
 
 public class UpdateBatchQueryBuilder extends BatchQueryBuilder {
@@ -42,14 +42,23 @@
     }
 
     @Override
-    public String createSqlString(BatchQuery batch) {
+    public String createSqlString(BatchQuery batch) throws IOException {
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) batch;
-        String table = batch.getDbEntity().getFullyQualifiedName();
+        boolean status;
+        if(batch.getDbEntity().getDataMap()!=null && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+
+        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
+        
         List<DbAttribute> qualifierAttributes = updateBatch.getQualifierAttributes();
         List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes();
 
         StringBuffer query = new StringBuffer("UPDATE ");
-        query.append(table).append(" SET ");
+        query.append(strategy.quoteFullyQualifiedName(batch.getDbEntity()));
+        query.append(" SET ");
 
         int len = updatedDbAttributes.size();
         for (int i = 0; i < len; i++) {
@@ -58,7 +67,8 @@
             }
 
             DbAttribute attribute = updatedDbAttributes.get(i);
-            query.append(attribute.getName()).append(" = ?");
+            query.append(strategy.quoteString(attribute.getName()));
+            query.append(" = ?");
         }
 
         query.append(" WHERE ");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/AutoAdapter.java Wed Feb  4 10:19:19 2009
@@ -331,4 +331,8 @@
         return  DEFAULT_QUOTE_SQL_IDENTIFIERS_CHAR_END;
     }
 
+    public QuotingStrategy  getQuotingStrategy(boolean isQuoteStrategy) {
+        return getAdapter().getQuotingStrategy(isQuoteStrategy);
+    }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DbAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DbAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DbAdapter.java Wed Feb  4 10:19:19 2009
@@ -203,11 +203,5 @@
     /**
      * @since 3.0
      */
-    String getIdentifiersStartQuote();
-
-    /**
-     * @since 3.0
-     */
-    String getIdentifiersEndQuote();
-
+    public QuotingStrategy getQuotingStrategy(boolean needQuotes);
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/JdbcAdapter.java Wed Feb  4 10:19:19 2009
@@ -43,7 +43,6 @@
 import org.apache.cayenne.access.types.ExtendedTypeMap;
 import org.apache.cayenne.access.types.UtilDateType;
 import org.apache.cayenne.conf.ClasspathResourceFinder;
-import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
@@ -267,7 +266,7 @@
      * @since 3.0
      */
     public Collection<String> dropTableStatements(DbEntity table) {
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap());
+        QuotingStrategy context =  getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
 
         StringBuffer buf = new StringBuffer("DROP TABLE ");
         buf.append(context.quoteFullyQualifiedName(table));
@@ -280,7 +279,13 @@
      * <code>ent</code> parameter.
      */
     public String createTable(DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
         StringBuffer sqlBuffer = new StringBuffer();
         sqlBuffer.append("CREATE TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(entity));
@@ -323,7 +328,13 @@
      * @since 1.2
      */
     protected void createTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+        if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
         Iterator<DbAttribute> pkit = entity.getPrimaryKeys().iterator();
         if (pkit.hasNext()) {
             sqlBuffer.append(", PRIMARY KEY (");
@@ -348,8 +359,14 @@
      * @since 1.2
      */
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
-        QuotingStrategy context = getContextQuoteStrategy(((DbEntity) column.getEntity())
-                .getDataMap());
+        boolean status;
+        if(((DbEntity) column.getEntity()).getDataMap()!=null && ((DbEntity) column.getEntity())
+                .getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
         String[] types = externalTypesForJdbcType(column.getType());
         if (types == null || types.length == 0) {
             String entityName = column.getEntity() != null ? ((DbEntity) column
@@ -396,7 +413,13 @@
      * @since 1.1
      */
     public String createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns) {
-        QuotingStrategy context = getContextQuoteStrategy(source.getDataMap());
+        boolean status;
+        if(source.getDataMap()!=null && source.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
 
         if (columns == null || columns.isEmpty()) {
             throw new CayenneRuntimeException(
@@ -431,7 +454,13 @@
     public String createFkConstraint(DbRelationship rel) {
 
         DbEntity source = (DbEntity) rel.getSourceEntity();
-        QuotingStrategy context = getContextQuoteStrategy(source.getDataMap());
+        boolean status;
+        if(source.getDataMap()!=null && source.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context =  getQuotingStrategy(status);
         StringBuilder buf = new StringBuilder();
         StringBuilder refBuf = new StringBuilder();
 
@@ -599,8 +628,8 @@
     /**
      * @since 3.0
      */
-    protected QuotingStrategy getContextQuoteStrategy(DataMap dm) {
-        if (dm != null && dm.isQuotingSQLIdentifiers()) {
+    public QuotingStrategy  getQuotingStrategy(boolean needQuotes) {
+        if (needQuotes) {
             return new QuoteStrategy(
                     getIdentifiersStartQuote(),
                     getIdentifiersEndQuote());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2Adapter.java Wed Feb  4 10:19:19 2009
@@ -81,7 +81,13 @@
      */
     @Override
     public String createTable(DbEntity ent) {
-        QuotingStrategy context = getContextQuoteStrategy(ent.getDataMap());
+        boolean status;
+        if(ent.getDataMap()!=null && ent.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyAdapter.java Wed Feb  4 10:19:19 2009
@@ -97,8 +97,14 @@
      */
     @Override
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
-        QuotingStrategy context = getContextQuoteStrategy(((DbEntity) column
-                .getEntity()).getDataMap());
+        
+        boolean status;
+        if(((DbEntity) column.getEntity()).getDataMap()!=null && ((DbEntity) column.getEntity()).getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         String[] types = externalTypesForJdbcType(column.getType());
         if (types == null || types.length == 0) {
             String entityName = column.getEntity() != null ? ((DbEntity) column

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/frontbase/FrontBaseAdapter.java Wed Feb  4 10:19:19 2009
@@ -90,7 +90,13 @@
      */
     @Override
     public String createTable(DbEntity ent) {
-        QuotingStrategy context = getContextQuoteStrategy(ent.getDataMap());
+        boolean status;
+        if(ent.getDataMap()!=null && ent.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
         buf.append(context.quoteFullyQualifiedName(ent));
@@ -200,7 +206,13 @@
      */
     @Override
     public Collection<String> dropTableStatements(DbEntity table) {
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap());
+        boolean status;
+        if(table.getDataMap()!=null && table.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         StringBuffer buf = new StringBuffer("DROP TABLE ");
         buf.append(context.quoteFullyQualifiedName(table));            
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java Wed Feb  4 10:19:19 2009
@@ -67,7 +67,7 @@
      * @since 1.2
      */
     protected String getTableName(DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(entity.getDataMap().isQuotingSQLIdentifiers());
         return context.quoteFullyQualifiedName(entity);
     }
 
@@ -78,7 +78,7 @@
      */
     protected String getSchemaName(DbEntity entity) {
         if (entity.getSchema() != null && entity.getSchema().length() > 0) {
-            QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+            QuotingStrategy context = getQuotingStrategy(entity.getDataMap().isQuotingSQLIdentifiers());
             return context.quoteString(entity.getSchema()) + ".";
         }
 
@@ -103,7 +103,13 @@
      */
     @Override
     public String createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns) {
-        QuotingStrategy context = getContextQuoteStrategy(source.getDataMap());
+        boolean status;
+        if(source.getDataMap()!=null && source.getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         if (columns == null || columns.isEmpty()) {
             throw new CayenneRuntimeException(
                     "Can't create UNIQUE constraint - no columns specified.");
@@ -144,7 +150,13 @@
      */
     @Override
     public String createFkConstraint(DbRelationship rel) {
-        QuotingStrategy context = getContextQuoteStrategy(((DbEntity)rel.getSourceEntity()).getDataMap());
+        boolean status;
+        if(((DbEntity)rel.getSourceEntity()).getDataMap()!=null && ((DbEntity)rel.getSourceEntity()).getDataMap().isQuotingSQLIdentifiers()){ 
+            status= true;
+        } else {
+            status = false;
+        }
+        QuotingStrategy context = getQuotingStrategy(status);
         StringBuilder buf = new StringBuilder();
         StringBuilder refBuf = new StringBuilder();
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java Wed Feb  4 10:19:19 2009
@@ -59,8 +59,8 @@
      * <code>ent</code> parameter.
      */
     @Override
-    public String createTable(DbEntity ent) {
-        QuotingStrategy context = getContextQuoteStrategy(ent.getDataMap());
+    public String createTable(DbEntity ent) {       
+        QuotingStrategy context = getQuotingStrategy(ent.getDataMap().isQuotingSQLIdentifiers());
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
         buf.append(context.quoteFullyQualifiedName(ent));

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLAdapter.java Wed Feb  4 10:19:19 2009
@@ -105,7 +105,7 @@
      */
     @Override
     public String dropTable(DbEntity table) {
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap()); 
+        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers()); 
         StringBuffer buf = new StringBuffer("DROP TABLE IF EXISTS ");
         buf.append(context.quoteFullyQualifiedName(table));            
         buf.append(" CASCADE");
@@ -120,7 +120,7 @@
         // note that CASCADE is a noop as of MySQL 5.0, so we have to use FK checks
         // statement
         StringBuffer buf = new StringBuffer();
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
         buf.append(context.quoteFullyQualifiedName(table));            
         
         return Arrays.asList("SET FOREIGN_KEY_CHECKS=0", "DROP TABLE IF EXISTS "
@@ -243,7 +243,13 @@
     // See CAY-358 for details of the InnoDB problem
     @Override
     protected void createTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity) {
-        QuotingStrategy context = getContextQuoteStrategy(entity.getDataMap());
+        boolean status;
+            if(entity.getDataMap()!=null && entity.getDataMap().isQuotingSQLIdentifiers()){ 
+                status= true;
+            } else {
+                status = false;
+            }
+        QuotingStrategy context = getQuotingStrategy(status);
         // must move generated to the front...
         List<DbAttribute> pkList = new ArrayList<DbAttribute>(entity.getPrimaryKeys());
         Collections.sort(pkList, new PKComparator());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBaseAdapter.java Wed Feb  4 10:19:19 2009
@@ -146,7 +146,7 @@
       */
     @Override
     public String createTable(DbEntity ent) {
-        QuotingStrategy context = getContextQuoteStrategy(ent.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(ent.getDataMap().isQuotingSQLIdentifiers());
         StringBuilder buf = new StringBuilder();
 
         buf.append("CREATE TABLE ");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleAdapter.java Wed Feb  4 10:19:19 2009
@@ -240,7 +240,7 @@
      */
     @Override
     public Collection<String> dropTableStatements(DbEntity table) {
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
         StringBuffer buf = new StringBuffer("DROP TABLE ");
         buf.append(context.quoteFullyQualifiedName(table));            
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java Wed Feb  4 10:19:19 2009
@@ -122,7 +122,7 @@
     @Override
     public String createTable(DbEntity ent) {
        
-        QuotingStrategy context = getContextQuoteStrategy(ent.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(ent.getDataMap().isQuotingSQLIdentifiers());
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
         
@@ -236,7 +236,7 @@
      */
     @Override
     public Collection<String> dropTableStatements(DbEntity table) {
-        QuotingStrategy context = getContextQuoteStrategy(table.getDataMap());
+        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
         StringBuffer buf = new StringBuffer("DROP TABLE ");
         buf.append(context.quoteFullyQualifiedName(table));            
         buf.append(" CASCADE");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/BatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/BatchQueryBuilderTest.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/BatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/BatchQueryBuilderTest.java Wed Feb  4 10:19:19 2009
@@ -27,6 +27,7 @@
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.query.BatchQuery;
 
 /**
@@ -61,12 +62,15 @@
 		builder.setTrimFunction(trimFunction);
 
 		StringBuffer buf = new StringBuffer();
+		DbEntity entity = new DbEntity("Test");
 		DbAttribute attr = new DbAttribute("testAttr", Types.CHAR, null);
+		attr.setEntity(entity);
 		builder.appendDbAttribute(buf, attr);
 		assertEquals("testTrim(testAttr)", buf.toString());
 
 		buf = new StringBuffer();
 		attr = new DbAttribute("testAttr", Types.VARCHAR, null);
+		attr.setEntity(entity);
 		builder.appendDbAttribute(buf, attr);
 		assertEquals("testAttr", buf.toString());
 	}
@@ -82,12 +86,17 @@
 		};
 
 		StringBuffer buf = new StringBuffer();
+		DbEntity entity = new DbEntity("Test");
+		
 		DbAttribute attr = new DbAttribute("testAttr", Types.CHAR, null);
+		attr.setEntity(entity);
 		builder.appendDbAttribute(buf, attr);
 		assertEquals("testAttr", buf.toString());
 
 		buf = new StringBuffer();
 		attr = new DbAttribute("testAttr", Types.VARCHAR, null);
+		attr.setEntity(entity);
+		
 		builder.appendDbAttribute(buf, attr);
 		assertEquals("testAttr", buf.toString());
 	}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/DeleteBatchQueryBuilderTest.java Wed Feb  4 10:19:19 2009
@@ -63,7 +63,8 @@
         DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
                 SimpleLockingTestEntity.class).getDbEntity();
 
-        List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
+        List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity
+                .getAttribute("NAME"));
 
         Collection nullAttributes = Collections.singleton("NAME");
 
@@ -79,4 +80,89 @@
                 + entity.getName()
                 + " WHERE LOCKING_TEST_ID = ? AND NAME IS NULL", generatedSql);
     }
+
+    public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
+        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+                SimpleLockingTestEntity.class).getDbEntity();
+        try {
+
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+            List idAttributes = Collections.singletonList(entity
+                    .getAttribute("LOCKING_TEST_ID"));
+
+            DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
+                    entity,
+                    idAttributes,
+                    null,
+                    1);
+            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(
+                    new JdbcAdapter());
+            String generatedSql = builder.createSqlString(deleteQuery);
+
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            String charStart = adapter.getIdentifiersStartQuote();
+            String charEnd = adapter.getIdentifiersEndQuote();
+
+            assertNotNull(generatedSql);
+            assertEquals("DELETE FROM "
+                    + charStart
+                    + entity.getName()
+                    + charEnd
+                    + " WHERE "
+                    + charStart
+                    + "LOCKING_TEST_ID"
+                    + charEnd
+                    + " = ?", generatedSql);
+        }
+        finally {
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+
+    }
+
+    public void testCreateSqlStringWithNullsWithIdentifiersQuote() throws Exception {
+        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+                SimpleLockingTestEntity.class).getDbEntity();
+        try {
+
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+
+            List idAttributes = Arrays.asList(
+                    entity.getAttribute("LOCKING_TEST_ID"),
+                    entity.getAttribute("NAME"));
+
+            Collection nullAttributes = Collections.singleton("NAME");
+
+            DeleteBatchQuery deleteQuery = new DeleteBatchQuery(
+                    entity,
+                    idAttributes,
+                    nullAttributes,
+                    1);
+            DeleteBatchQueryBuilder builder = new DeleteBatchQueryBuilder(
+                    new JdbcAdapter());
+            String generatedSql = builder.createSqlString(deleteQuery);
+
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            String charStart = adapter.getIdentifiersStartQuote();
+            String charEnd = adapter.getIdentifiersEndQuote();
+            assertNotNull(generatedSql);
+
+            assertEquals("DELETE FROM "
+                    + charStart
+                    + entity.getName()
+                    + charEnd
+                    + " WHERE "
+                    + charStart
+                    + "LOCKING_TEST_ID"
+                    + charEnd
+                    + " = ? AND "
+                    + charStart
+                    + "NAME"
+                    + charEnd
+                    + " IS NULL", generatedSql);
+        }
+        finally {
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/trans/UpdateBatchQueryBuilderTest.java Wed Feb  4 10:19:19 2009
@@ -68,7 +68,8 @@
         DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
                 SimpleLockingTestEntity.class).getDbEntity();
 
-        List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity.getAttribute("NAME"));
+        List idAttributes = Arrays.asList(entity.getAttribute("LOCKING_TEST_ID"), entity
+                .getAttribute("NAME"));
 
         List updatedAttributes = Collections.singletonList(entity
                 .getAttribute("DESCRIPTION"));
@@ -84,6 +85,7 @@
         UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(new JdbcAdapter());
         String generatedSql = builder.createSqlString(updateQuery);
         assertNotNull(generatedSql);
+
         assertEquals(
                 "UPDATE "
                         + entity.getName()
@@ -91,4 +93,102 @@
                 generatedSql);
     }
 
+    public void testCreateSqlStringWithIdentifiersQuote() throws Exception {
+        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+                SimpleLockingTestEntity.class).getDbEntity();
+        try {
+
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+            List idAttributes = Collections.singletonList(entity
+                    .getAttribute("LOCKING_TEST_ID"));
+            List updatedAttributes = Collections.singletonList(entity
+                    .getAttribute("DESCRIPTION"));
+
+            UpdateBatchQuery updateQuery = new UpdateBatchQuery(
+                    entity,
+                    idAttributes,
+                    updatedAttributes,
+                    null,
+                    1);
+            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(
+                    new JdbcAdapter());
+            String generatedSql = builder.createSqlString(updateQuery);
+            
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            String charStart = adapter.getIdentifiersStartQuote();
+            String charEnd = adapter.getIdentifiersEndQuote();
+            
+            assertNotNull(generatedSql);
+             assertEquals("UPDATE "
+             + charStart
+             + entity.getName()
+             + charEnd
+             + " SET "
+             + charStart
+             + "DESCRIPTION"
+             + charEnd
+             + " = ? WHERE "
+             + charStart
+             + "LOCKING_TEST_ID"
+             + charEnd
+             + " = ?", generatedSql);
+
+        }
+        finally {
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
+
+    public void testCreateSqlStringWithNullsWithIdentifiersQuote() throws Exception {
+        DbEntity entity = getDomain().getEntityResolver().lookupObjEntity(
+                SimpleLockingTestEntity.class).getDbEntity();
+        try {
+
+            entity.getDataMap().setQuotingSQLIdentifiers(true);
+            List idAttributes = Arrays.asList(
+                    entity.getAttribute("LOCKING_TEST_ID"),
+                    entity.getAttribute("NAME"));
+
+            List updatedAttributes = Collections.singletonList(entity
+                    .getAttribute("DESCRIPTION"));
+
+            Collection nullAttributes = Collections.singleton("NAME");
+
+            UpdateBatchQuery updateQuery = new UpdateBatchQuery(
+                    entity,
+                    idAttributes,
+                    updatedAttributes,
+                    nullAttributes,
+                    1);
+            UpdateBatchQueryBuilder builder = new UpdateBatchQueryBuilder(
+                    new JdbcAdapter());
+            String generatedSql = builder.createSqlString(updateQuery);
+            assertNotNull(generatedSql);
+            JdbcAdapter adapter = (JdbcAdapter) getAccessStackAdapter().getAdapter();
+            String charStart = adapter.getIdentifiersStartQuote();
+            String charEnd = adapter.getIdentifiersEndQuote();
+            assertEquals("UPDATE "
+                    + charStart
+                    + entity.getName()
+                    + charEnd
+                    + " SET "
+                    + charStart
+                    + "DESCRIPTION"
+                    + charEnd
+                    + " = ? WHERE "
+                    + charStart
+                    + "LOCKING_TEST_ID"
+                    + charEnd
+                    + " = ? AND "
+                    + charStart
+                    + "NAME"
+                    + charEnd
+                    + " IS NULL", generatedSql);
+
+        }
+        finally {
+            entity.getDataMap().setQuotingSQLIdentifiers(false);
+        }
+    }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java?rev=740672&r1=740671&r2=740672&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/MockDbAdapter.java Wed Feb  4 10:19:19 2009
@@ -152,4 +152,8 @@
     public String getIdentifiersEndQuote(){
         return "\"";
     }
+    
+    public QuotingStrategy getQuotingStrategy(boolean isQuoteStrategy) {
+        return null;
+    }
 }



Mime
View raw message