cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1449462 [1/3] - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/ main/java/org/apache/cayenne/access/jdbc/ main/java/org/apache/cayenne/access/trans/ main/java/org/apache/cayenne/dba/ ma...
Date Sun, 24 Feb 2013 11:53:38 GMT
Author: aadamchik
Date: Sun Feb 24 11:53:37 2013
New Revision: 1449462

URL: http://svn.apache.org/r1449462
Log:
CAY-1522 EJBQL query don't support quotes

preliminary refactoring to fold in quote/no-quote detection inside the strategy
(same idea as Ilya's patches, only alos folding QuotingSupport into QuotingStrategy)

Removed:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/NoQuotingStrategy.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/NoQuotingStrategyTest.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
    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/jdbc/SoftDeleteBatchQueryBuilder.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/LOBBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBInsertBatchQueryBuilder.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBUpdateBatchQueryBuilder.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/DefaultQuotingStrategy.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/QuotingStrategy.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/db2/DB2MergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.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/derby/DerbyMergerFactory.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/h2/H2MergerFactory.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/hsqldb/HSQLDBNoSchemaAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.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/ingres/IngresMergerFactory.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/mysql/MySQLMergerFactory.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/openbase/OpenBasePkGenerator.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/oracle/OracleMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.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/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetPrimaryKeyToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/dba/DefaultQuotingStrategyTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelperProvider.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java Sun Feb 24 11:53:37 2013
@@ -163,16 +163,7 @@ final class FlattenedArcKey {
         // DeleteBatchQuery
         // expects a PK snapshot, so we must provide it.
 
-        final boolean quotesNeeded;
-        if (joinEntity.getDataMap() != null
-                && joinEntity.getDataMap().isQuotingSQLIdentifiers()) {
-            quotesNeeded = true;
-        } else {
-            quotesNeeded = false;
-        }
-
-        QuotingStrategy quoter = node.getAdapter().getQuotingStrategy(
-                quotesNeeded);
+        QuotingStrategy quoter = node.getAdapter().getQuotingStrategy();
 
         StringBuilder sql = new StringBuilder("SELECT ");
         Collection<DbAttribute> pk = joinEntity.getPrimaryKeys();
@@ -188,19 +179,13 @@ final class FlattenedArcKey {
             DbAttribute attribute = pkList.get(i);
 
             sql.append("#result('");
-            sql.append(quoter.quotedIdentifier(attribute.getName()));
-
-            if (quotesNeeded) {
-                // since the name of the column can potentially be quoted and
-                // use reserved
-                // keywords as name, let's specify
-                // generated column name parameters to ensure the query doesn't
-                // explode
-                sql.append("' '").append(
-                        TypesMapping.getJavaBySqlType(attribute.getType()));
-                sql.append("' '").append("pk").append(i);
-            }
+            sql.append(quoter.quotedName(attribute));
 
+            // since the name of the column can potentially be quoted and
+            // use reserved keywords as name, let's specify generated column
+            // name parameters to ensure the query doesn't explode
+            sql.append("' '").append(TypesMapping.getJavaBySqlType(attribute.getType()));
+            sql.append("' '").append("pk").append(i);
             sql.append("')");
         }
 
@@ -208,7 +193,7 @@ final class FlattenedArcKey {
                 .append(" WHERE ");
         int i = snapshot.size();
         for (Object key : snapshot.keySet()) {
-            sql.append(quoter.quotedIdentifier(String.valueOf(key)))
+            sql.append(quoter.quotedIdentifier(joinEntity, String.valueOf(key)))
                     .append(" #bindEqual($").append(key).append(")");
 
             if (--i > 0) {
@@ -228,7 +213,7 @@ final class FlattenedArcKey {
                     @Override
                     public void nextRows(Query query, List dataRows) {
 
-                        if (quotesNeeded && !dataRows.isEmpty()) {
+                        if (!dataRows.isEmpty()) {
                             // decode results...
 
                             List<DataRow> fixedRows = new ArrayList<DataRow>(

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -23,7 +23,6 @@ import java.io.Serializable;
 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;
@@ -189,10 +188,6 @@ public class ColumnDescriptor implements
         return (namePrefix != null) ? namePrefix + '.' + name : name;
     }
 
-    public String getQualifiedColumnNameWithQuoteSqlIdentifiers(QuotingStrategy strategy) {
-        return strategy.quotedIdentifier(namePrefix, name);
-    }
-
     public int getJdbcType() {
         return jdbcType;
     }
@@ -203,6 +198,13 @@ public class ColumnDescriptor implements
     public String getName() {
         return name;
     }
+    
+    /**
+     * @since 3.2
+     */
+    public String getNamePrefix() {
+        return namePrefix;
+    }
 
     public void setJdbcType(int i) {
         jdbcType = i;

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SoftDeleteBatchQueryBuilder.java Sun Feb 24 11:53:37 2013
@@ -30,8 +30,8 @@ import org.apache.cayenne.map.DbAttribut
 import org.apache.cayenne.query.BatchQuery;
 
 /**
- * Implementation of {@link DeleteBatchQueryBuilder}, which uses 'soft' delete (runs
- * UPDATE and sets 'deleted' field to true instead-of running SQL DELETE)
+ * Implementation of {@link DeleteBatchQueryBuilder}, which uses 'soft' delete
+ * (runs UPDATE and sets 'deleted' field to true instead-of running SQL DELETE)
  */
 public class SoftDeleteBatchQueryBuilder extends DeleteBatchQueryBuilder {
 
@@ -48,15 +48,11 @@ public class SoftDeleteBatchQueryBuilder
             return super.createSqlString(batch);
         }
 
-        boolean status = batch.getDbEntity().getDataMap() != null
-                && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers();
-
-        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
 
         StringBuffer query = new StringBuffer("UPDATE ");
         query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
-        query.append(" SET ").append(strategy.quotedIdentifier(deletedFieldName)).append(
-                " = ?");
+        query.append(" SET ").append(strategy.quotedIdentifier(batch.getDbEntity(), deletedFieldName)).append(" = ?");
 
         applyQualifier(query, batch);
 
@@ -69,8 +65,7 @@ public class SoftDeleteBatchQueryBuilder
     }
 
     @Override
-    public void bindParameters(PreparedStatement statement, BatchQuery query)
-            throws SQLException, Exception {
+    public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception {
         if (needSoftDelete(query)) {
             // binding first parameter (which is 'deleted') as true
             adapter.bindParameter(statement, true, 1, Types.BOOLEAN, -1);
@@ -83,8 +78,7 @@ public class SoftDeleteBatchQueryBuilder
      * @return whether 'soft' deletion should be used
      */
     protected boolean needSoftDelete(BatchQuery query) {
-        DbAttribute attr = (DbAttribute) query.getDbEntity().getAttribute(
-                deletedFieldName);
+        DbAttribute attr = (DbAttribute) query.getDbEntity().getAttribute(deletedFieldName);
         return attr != null && attr.getType() == Types.BOOLEAN;
     }
 }

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -70,9 +70,9 @@ public abstract class BatchQueryBuilder 
         else {
             status = false;
         }
-        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
 
-        buf.append(strategy.quotedIdentifier(dbAttribute.getName()));
+        buf.append(strategy.quotedName(dbAttribute));
 
         if (trim) {
             buf.append(')');

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -31,7 +31,8 @@ import org.apache.cayenne.query.BatchQue
 import org.apache.cayenne.query.DeleteBatchQuery;
 
 /**
- * Translator for delete BatchQueries. Creates parametrized DELETE SQL statements.
+ * Translator for delete BatchQueries. Creates parameterized DELETE SQL
+ * statements.
  */
 public class DeleteBatchQueryBuilder extends BatchQueryBuilder {
 
@@ -41,11 +42,9 @@ public class DeleteBatchQueryBuilder ext
 
     @Override
     public String createSqlString(BatchQuery batch) throws IOException {
-        boolean status = batch.getDbEntity().getDataMap() != null 
-            && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers();
-        
-        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
-       
+
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
+
         StringBuffer query = new StringBuffer("DELETE FROM ");
         query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
 
@@ -53,13 +52,13 @@ public class DeleteBatchQueryBuilder ext
 
         return query.toString();
     }
-    
+
     /**
      * Appends WHERE clause to SQL string
      */
     protected void applyQualifier(StringBuffer query, BatchQuery batch) {
         query.append(" WHERE ");
-        
+
         DeleteBatchQuery deleteBatch = (DeleteBatchQuery) batch;
         Iterator<DbAttribute> i = deleteBatch.getQualifierAttributes().iterator();
         while (i.hasNext()) {
@@ -77,8 +76,7 @@ public class DeleteBatchQueryBuilder ext
      * Binds BatchQuery parameters to the PreparedStatement.
      */
     @Override
-    public void bindParameters(PreparedStatement statement, BatchQuery query)
-            throws SQLException, Exception {
+    public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception {
 
         DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query;
 
@@ -93,17 +91,12 @@ public class DeleteBatchQueryBuilder ext
                 continue;
             }
 
-            adapter.bindParameter(
-                    statement,
-                    value,
-                    parameterIndex++,
-                    attribute.getType(),
-                    attribute.getScale());
+            adapter.bindParameter(statement, value, parameterIndex++, attribute.getType(), attribute.getScale());
         }
     }
-    
+
     /**
-     * @return index of first parameter in delete clause 
+     * @return index of first parameter in delete clause
      */
     protected int getFirstParameterIndex(BatchQuery query) {
         return 1;

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -88,13 +88,7 @@ public class InsertBatchQueryBuilder ext
     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);
+        QuotingStrategy strategy =  getAdapter().getQuotingStrategy();
 
         StringBuilder query = new StringBuilder("INSERT INTO ");
         query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
@@ -113,7 +107,7 @@ public class InsertBatchQueryBuilder ext
                 if (columnCount > 0) {
                     query.append(", ");
                 }
-                query.append(strategy.quotedIdentifier(attribute.getName()));
+                query.append(strategy.quotedName(attribute));
                 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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -59,14 +59,9 @@ public class JoinStack {
     protected JoinStack(DbAdapter dbAdapter, DataMap dataMap, QueryAssembler assembler) {
         this.rootNode = new JoinTreeNode(this);
         this.rootNode.setTargetTableAlias(newAlias());
-        boolean status;
-        if (dataMap != null && dataMap.isQuotingSQLIdentifiers()) {
-            status = true;
-        } else {
-            status = false;
-        }
-        quotingStrategy = dbAdapter.getQuotingStrategy(status);
-        qualifierTranslator = dbAdapter.getQualifierTranslator(assembler);
+
+        this.quotingStrategy = dbAdapter.getQuotingStrategy();
+        this.qualifierTranslator = dbAdapter.getQualifierTranslator(assembler);
 
         resetStack();
     }
@@ -87,7 +82,7 @@ public class JoinStack {
 
         out.append(quotingStrategy.quotedFullyQualifiedName(rootEntity));
         out.append(' ');
-        out.append(quotingStrategy.quotedIdentifier(rootNode.getTargetTableAlias()));
+        out.append(quotingStrategy.quotedIdentifier(rootEntity, rootNode.getTargetTableAlias()));
     }
 
     /**
@@ -124,7 +119,7 @@ public class JoinStack {
         out.append(quotingStrategy.quotedFullyQualifiedName(targetEntity));
 
         out.append(' ');
-        out.append(quotingStrategy.quotedIdentifier(targetAlias));
+        out.append(quotingStrategy.quotedIdentifier(targetEntity, targetAlias));
         out.append(" ON (");
 
         List<DbJoin> joins = relationship.getJoins();
@@ -135,9 +130,9 @@ public class JoinStack {
                 out.append(" AND ");
             }
 
-            out.append(quotingStrategy.quotedIdentifier(srcAlias, join.getSourceName()));
+            out.append(quotingStrategy.quotedIdentifier(relationship.getSourceEntity(), srcAlias, join.getSourceName()));
             out.append(" = ");
-            out.append(quotingStrategy.quotedIdentifier(targetAlias, join.getTargetName()));
+            out.append(quotingStrategy.quotedIdentifier(targetEntity, targetAlias, join.getTargetName()));
         }
 
         /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryBuilder.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBBatchQueryBuilder.java Sun Feb 24 11:53:37 2013
@@ -53,22 +53,14 @@ public abstract class LOBBatchQueryBuild
             List selectedLOBAttributes,
             List qualifierAttributes) {
 
-        boolean status;
-        if (updateQuery.getDbEntity().getDataMap() != null
-                && updateQuery.getDbEntity().getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
-        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
 
 		StringBuffer buf = new StringBuffer();
 		buf.append("SELECT ");
 
         Iterator it = selectedLOBAttributes.iterator();
         while (it.hasNext()) {
-            buf.append(strategy.quotedIdentifier(((DbAttribute) it.next()).getName()));
+            buf.append(strategy.quotedName((DbAttribute) it.next()));
 
             if (it.hasNext()) {
                 buf.append(", ");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBInsertBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBInsertBatchQueryBuilder.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBInsertBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBInsertBatchQueryBuilder.java Sun Feb 24 11:53:37 2013
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access.trans;
 
 import java.util.ArrayList;
@@ -52,41 +51,32 @@ public class LOBInsertBatchQueryBuilder 
         return values;
     }
 
-	@Override
-	public String createSqlString(BatchQuery batch) {
-		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);
-
-		StringBuffer query = new StringBuffer("INSERT INTO ");
-		query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
-		query.append(" (");
-
-		for (Iterator<DbAttribute> i = dbAttributes.iterator(); i.hasNext();) {
-			DbAttribute attribute = i.next();
-			query.append(strategy.quotedIdentifier(attribute.getName()));
-			if (i.hasNext()) {
-				query.append(", ");
-			}
-		}
-		query.append(") VALUES (");
-		for (int i = 0; i < dbAttributes.size(); i++) {
-			if (i > 0) {
-				query.append(", ");
-			}
-
-			appendUpdatedParameter(
-					query,
-					dbAttributes.get(i),
-					batch.getValue(i));
-		}
-		query.append(')');
-		return query.toString();
-	}
+    @Override
+    public String createSqlString(BatchQuery batch) {
+        List<DbAttribute> dbAttributes = batch.getDbAttributes();
+
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
+
+        StringBuffer query = new StringBuffer("INSERT INTO ");
+        query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
+        query.append(" (");
+
+        for (Iterator<DbAttribute> i = dbAttributes.iterator(); i.hasNext();) {
+            DbAttribute attribute = i.next();
+            query.append(strategy.quotedName(attribute));
+            if (i.hasNext()) {
+                query.append(", ");
+            }
+        }
+        query.append(") VALUES (");
+        for (int i = 0; i < dbAttributes.size(); i++) {
+            if (i > 0) {
+                query.append(", ");
+            }
+
+            appendUpdatedParameter(query, dbAttributes.get(i), batch.getValue(i));
+        }
+        query.append(')');
+        return query.toString();
+    }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBUpdateBatchQueryBuilder.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBUpdateBatchQueryBuilder.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBUpdateBatchQueryBuilder.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/LOBUpdateBatchQueryBuilder.java Sun Feb 24 11:53:37 2013
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.access.trans;
 
 import java.util.ArrayList;
@@ -50,13 +49,13 @@ public class LOBUpdateBatchQueryBuilder 
         for (int i = 0; i < updatedLen; i++) {
             DbAttribute attribute = updatedDbAttributes.get(i);
             Object value = query.getValue(i);
-            if(isUpdateableColumn(value, attribute.getType())) {
-            	values.add(value);
+            if (isUpdateableColumn(value, attribute.getType())) {
+                values.add(value);
             }
         }
 
-		for (int i = 0; i < qualifierLen; i++) {
-			values.add(query.getValue(updatedLen + i));
+        for (int i = 0; i < qualifierLen; i++) {
+            values.add(query.getValue(updatedLen + i));
         }
 
         return values;
@@ -67,20 +66,12 @@ public class LOBUpdateBatchQueryBuilder 
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) batch;
         List<DbAttribute> idDbAttributes = updateBatch.getQualifierAttributes();
         List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes();
-		
-		boolean status;
-        if (batch.getDbEntity().getDataMap() != null
-                && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
-        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
-		
+
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
+
         StringBuffer query = new StringBuffer("UPDATE ");
-		query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
-		query.append(" SET ");
+        query.append(strategy.quotedFullyQualifiedName(batch.getDbEntity()));
+        query.append(" SET ");
 
         int len = updatedDbAttributes.size();
         for (int i = 0; i < len; i++) {
@@ -89,8 +80,8 @@ public class LOBUpdateBatchQueryBuilder 
             }
 
             DbAttribute attribute = updatedDbAttributes.get(i);
-            query.append(strategy.quotedIdentifier(attribute.getName()));
-			query.append(" = ");
+            query.append(strategy.quotedName(attribute));
+            query.append(" = ");
             appendUpdatedParameter(query, attribute, batch.getValue(i));
         }
 

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -59,14 +59,7 @@ public abstract class QueryAssemblerHelp
      */
     public QueryAssemblerHelper(QueryAssembler queryAssembler) {
         this.queryAssembler = queryAssembler;
-        boolean status;
-        if (queryAssembler.getQueryMetadata().getDataMap() != null
-                && queryAssembler.getQueryMetadata().getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        } else {
-            status = false;
-        }
-        strategy = queryAssembler.getAdapter().getQuotingStrategy(status);
+        strategy = queryAssembler.getAdapter().getQuotingStrategy();
     }
 
     public ObjEntity getObjEntity() {
@@ -251,7 +244,7 @@ public abstract class QueryAssemblerHelp
     protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) throws IOException {
 
         String alias = (queryAssembler.supportsTableAliases()) ? queryAssembler.getCurrentAlias() : null;
-        out.append(strategy.quotedIdentifier(alias, dbAttr.getName()));
+        out.append(strategy.quotedIdentifier(dbAttr.getEntity(), alias, 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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -33,6 +33,7 @@ import org.apache.cayenne.CayenneRuntime
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
 import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.exp.Expression;
+import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
@@ -56,15 +57,14 @@ import org.apache.cayenne.util.EqualsBui
 import org.apache.cayenne.util.HashCodeBuilder;
 
 /**
- * A builder of JDBC PreparedStatements based on Cayenne SelectQueries. Translates
- * SelectQuery to parameterized SQL string and wraps it in a PreparedStatement.
- * SelectTranslator is stateful and thread-unsafe.
+ * A builder of JDBC PreparedStatements based on Cayenne SelectQueries.
+ * Translates SelectQuery to parameterized SQL string and wraps it in a
+ * PreparedStatement. SelectTranslator is stateful and thread-unsafe.
  */
 public class SelectTranslator extends QueryAssembler {
 
-    protected static final int[] UNSUPPORTED_DISTINCT_TYPES = new int[] {
-            Types.BLOB, Types.CLOB, Types.LONGVARBINARY, Types.LONGVARCHAR
-    };
+    protected static final int[] UNSUPPORTED_DISTINCT_TYPES = new int[] { Types.BLOB, Types.CLOB, Types.LONGVARBINARY,
+            Types.LONGVARCHAR };
 
     protected static boolean isUnsupportedForDistinct(int type) {
         for (int i = 0; i < UNSUPPORTED_DISTINCT_TYPES.length; i++) {
@@ -92,9 +92,9 @@ public class SelectTranslator extends Qu
     boolean suppressingDistinct;
 
     /**
-     * If set to <code>true</code>, indicates that distinct select query is required no
-     * matter what the original query settings where. This flag can be set when joins are
-     * created using "to-many" relationships.
+     * If set to <code>true</code>, indicates that distinct select query is
+     * required no matter what the original query settings where. This flag can
+     * be set when joins are created using "to-many" relationships.
      */
     boolean forcingDistinct;
 
@@ -109,17 +109,10 @@ public class SelectTranslator extends Qu
     @Override
     public String createSqlString() throws Exception {
 
+        DataMap dataMap = queryMetadata.getDataMap();
         JoinStack joins = getJoinStack();
-        boolean status;
-        if (queryMetadata.getDataMap() != null
-                && queryMetadata.getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
 
-        QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
         forcingDistinct = false;
 
         // build column list
@@ -127,8 +120,7 @@ public class SelectTranslator extends Qu
 
         // build qualifier
         QualifierTranslator qualifierTranslator = adapter.getQualifierTranslator(this);
-        StringBuilder qualifierBuffer = qualifierTranslator
-                .appendPart(new StringBuilder());
+        StringBuilder qualifierBuffer = qualifierTranslator.appendPart(new StringBuilder());
 
         // build ORDER BY
         OrderingTranslator orderingTranslator = new OrderingTranslator(this);
@@ -158,8 +150,8 @@ public class SelectTranslator extends Qu
         // convert ColumnDescriptors to column names
         List<String> selectColumnExpList = new ArrayList<String>();
         for (ColumnDescriptor column : resultColumns) {
-            selectColumnExpList.add(column
-                    .getQualifiedColumnNameWithQuoteSqlIdentifiers(strategy));
+            String fullName = strategy.quotedIdentifier(dataMap, column.getNamePrefix(), column.getName());
+            selectColumnExpList.add(fullName);
         }
 
         // append any column expressions used in the order by if this query
@@ -205,12 +197,12 @@ public class SelectTranslator extends Qu
 
         return queryBuf.toString();
     }
-    
+
     /**
      * @since 3.1
      */
     protected void appendSelectColumns(StringBuilder buffer, List<String> selectColumnExpList) {
-        
+
         // append columns (unroll the loop's first element)
         int columnCount = selectColumnExpList.size();
         buffer.append(selectColumnExpList.get(0));
@@ -223,8 +215,9 @@ public class SelectTranslator extends Qu
     }
 
     /**
-     * Handles appending optional limit and offset clauses. This implementation does
-     * nothing, deferring to subclasses to define the LIMIT/OFFSET clause syntax.
+     * Handles appending optional limit and offset clauses. This implementation
+     * does nothing, deferring to subclasses to define the LIMIT/OFFSET clause
+     * syntax.
      * 
      * @since 3.0
      */
@@ -251,25 +244,25 @@ public class SelectTranslator extends Qu
     }
 
     /**
-     * Returns a map of ColumnDescriptors keyed by ObjAttribute for columns that may need
-     * to be reprocessed manually due to incompatible mappings along the inheritance
-     * hierarchy.
+     * Returns a map of ColumnDescriptors keyed by ObjAttribute for columns that
+     * may need to be reprocessed manually due to incompatible mappings along
+     * the inheritance hierarchy.
      * 
      * @since 1.2
      */
     public Map<ObjAttribute, ColumnDescriptor> getAttributeOverrides() {
         if (attributeOverrides != null) {
             return attributeOverrides;
-        }
-        else {
+        } else {
             return Collections.emptyMap();
         }
     }
 
     /**
-     * Returns true if SelectTranslator determined that a query requiring DISTINCT can't
-     * be run with DISTINCT keyword for internal reasons. If this method returns true,
-     * DataNode may need to do in-memory distinct filtering.
+     * Returns true if SelectTranslator determined that a query requiring
+     * DISTINCT can't be run with DISTINCT keyword for internal reasons. If this
+     * method returns true, DataNode may need to do in-memory distinct
+     * filtering.
      * 
      * @since 1.1
      */
@@ -290,20 +283,16 @@ public class SelectTranslator extends Qu
 
         if (query.getRoot() instanceof DbEntity) {
             appendDbEntityColumns(columns, query);
-        }
-        else if (getQueryMetadata().getPageSize() > 0) {
+        } else if (getQueryMetadata().getPageSize() > 0) {
             appendIdColumns(columns, query);
-        }
-        else {
+        } else {
             appendQueryColumns(columns, query);
         }
 
         return columns;
     }
 
-    <T> List<ColumnDescriptor> appendDbEntityColumns(
-            List<ColumnDescriptor> columns,
-            SelectQuery<T> query) {
+    <T> List<ColumnDescriptor> appendDbEntityColumns(List<ColumnDescriptor> columns, SelectQuery<T> query) {
 
         final Set<ColumnTracker> attributes = new HashSet<ColumnTracker>();
 
@@ -316,16 +305,15 @@ public class SelectTranslator extends Qu
     }
 
     /**
-     * Appends columns needed for object SelectQuery to the provided columns list.
+     * Appends columns needed for object SelectQuery to the provided columns
+     * list.
      */
-    <T> List<ColumnDescriptor> appendQueryColumns(
-            final List<ColumnDescriptor> columns,
-            SelectQuery<T> query) {
+    <T> List<ColumnDescriptor> appendQueryColumns(final List<ColumnDescriptor> columns, SelectQuery<T> query) {
 
         final Set<ColumnTracker> attributes = new HashSet<ColumnTracker>();
 
         // fetched attributes include attributes that are either:
-        // 
+        //
         // * class properties
         // * PK
         // * FK used in relationship
@@ -345,14 +333,11 @@ public class SelectTranslator extends Qu
                     Object pathPart = dbPathIterator.next();
 
                     if (pathPart == null) {
-                        throw new CayenneRuntimeException(
-                                "ObjAttribute has no component: " + oa.getName());
-                    }
-                    else if (pathPart instanceof DbRelationship) {
+                        throw new CayenneRuntimeException("ObjAttribute has no component: " + oa.getName());
+                    } else if (pathPart instanceof DbRelationship) {
                         DbRelationship rel = (DbRelationship) pathPart;
                         dbRelationshipAdded(rel, JoinType.LEFT_OUTER, null);
-                    }
-                    else if (pathPart instanceof DbAttribute) {
+                    } else if (pathPart instanceof DbAttribute) {
                         DbAttribute dbAttr = (DbAttribute) pathPart;
 
                         appendColumn(columns, oa, dbAttr, attributes, null);
@@ -373,7 +358,7 @@ public class SelectTranslator extends Qu
 
             private void visitRelationship(ArcProperty property) {
                 resetJoinStack();
-                
+
                 ObjRelationship rel = property.getRelationship();
                 DbRelationship dbRel = rel.getDbRelationships().get(0);
 
@@ -388,8 +373,9 @@ public class SelectTranslator extends Qu
         };
 
         descriptor.visitAllProperties(visitor);
-        
-        //stack should be reset, because all root table attributes go with "t0" table alias
+
+        // stack should be reset, because all root table attributes go with "t0"
+        // table alias
         resetJoinStack();
 
         // add remaining needed attrs from DbEntity
@@ -416,8 +402,7 @@ public class SelectTranslator extends Qu
                         .resolvePath(pathExp, getPathAliases())) {
 
                     if (component.getRelationship() != null) {
-                        dbRelationshipAdded(component.getRelationship(), component
-                                .getJoinType(), null);
+                        dbRelationshipAdded(component.getRelationship(), component.getJoinType(), null);
                     }
 
                     lastComponent = component;
@@ -435,11 +420,10 @@ public class SelectTranslator extends Qu
 
                         for (DbAttribute pk : targetEntity.getPrimaryKeys()) {
 
-                            // note that we my select a source attribute, but label it as
+                            // note that we my select a source attribute, but
+                            // label it as
                             // target for simplified snapshot processing
-                            appendColumn(columns, null, pk, attributes, labelPrefix
-                                    + '.'
-                                    + pk.getName());
+                            appendColumn(columns, null, pk, attributes, labelPrefix + '.' + pk.getName());
                         }
                     }
                 }
@@ -451,35 +435,35 @@ public class SelectTranslator extends Qu
 
             for (PrefetchTreeNode prefetch : query.getPrefetchTree().adjacentJointNodes()) {
 
-                // for each prefetch add all joins plus columns from the target entity
+                // for each prefetch add all joins plus columns from the target
+                // entity
                 Expression prefetchExp = Expression.fromString(prefetch.getPath());
                 Expression dbPrefetch = oe.translateToDbPath(prefetchExp);
 
                 resetJoinStack();
                 DbRelationship r = null;
-                for (PathComponent<DbAttribute, DbRelationship> component : table
-                        .resolvePath(dbPrefetch, getPathAliases())) {
+                for (PathComponent<DbAttribute, DbRelationship> component : table.resolvePath(dbPrefetch,
+                        getPathAliases())) {
                     r = component.getRelationship();
                     dbRelationshipAdded(r, JoinType.LEFT_OUTER, null);
                 }
 
                 if (r == null) {
-                    throw new CayenneRuntimeException("Invalid joint prefetch '"
-                            + prefetch
-                            + "' for entity: "
+                    throw new CayenneRuntimeException("Invalid joint prefetch '" + prefetch + "' for entity: "
                             + oe.getName());
                 }
 
-                // add columns from the target entity, including those that are matched
-                // against the FK of the source entity. This is needed to determine
+                // add columns from the target entity, including those that are
+                // matched
+                // against the FK of the source entity. This is needed to
+                // determine
                 // whether optional relationships are null
 
-                // go via target OE to make sure that Java types are mapped correctly...
+                // go via target OE to make sure that Java types are mapped
+                // correctly...
                 ObjRelationship targetRel = (ObjRelationship) prefetchExp.evaluate(oe);
-                Iterator<ObjAttribute> targetObjAttrs = (Iterator<ObjAttribute>) targetRel
-                        .getTargetEntity()
-                        .getAttributes()
-                        .iterator();
+                Iterator<ObjAttribute> targetObjAttrs = (Iterator<ObjAttribute>) targetRel.getTargetEntity()
+                        .getAttributes().iterator();
 
                 String labelPrefix = dbPrefetch.toString().substring("db:".length());
                 while (targetObjAttrs.hasNext()) {
@@ -489,33 +473,24 @@ public class SelectTranslator extends Qu
                         Object pathPart = dbPathIterator.next();
 
                         if (pathPart == null) {
-                            throw new CayenneRuntimeException(
-                                    "ObjAttribute has no component: " + oa.getName());
-                        }
-                        else if (pathPart instanceof DbRelationship) {
+                            throw new CayenneRuntimeException("ObjAttribute has no component: " + oa.getName());
+                        } else if (pathPart instanceof DbRelationship) {
                             DbRelationship rel = (DbRelationship) pathPart;
                             dbRelationshipAdded(rel, JoinType.INNER, null);
-                        }
-                        else if (pathPart instanceof DbAttribute) {
+                        } else if (pathPart instanceof DbAttribute) {
                             DbAttribute attribute = (DbAttribute) pathPart;
 
-                            appendColumn(columns, oa, attribute, attributes, labelPrefix
-                                    + '.'
-                                    + attribute.getName());
+                            appendColumn(columns, oa, attribute, attributes, labelPrefix + '.' + attribute.getName());
                         }
                     }
                 }
 
                 // append remaining target attributes such as keys
-                Iterator<DbAttribute> targetAttributes = (Iterator<DbAttribute>) r
-                        .getTargetEntity()
-                        .getAttributes()
+                Iterator<DbAttribute> targetAttributes = (Iterator<DbAttribute>) r.getTargetEntity().getAttributes()
                         .iterator();
                 while (targetAttributes.hasNext()) {
                     DbAttribute attribute = targetAttributes.next();
-                    appendColumn(columns, null, attribute, attributes, labelPrefix
-                            + '.'
-                            + attribute.getName());
+                    appendColumn(columns, null, attribute, attributes, labelPrefix + '.' + attribute.getName());
                 }
             }
         }
@@ -523,9 +498,7 @@ public class SelectTranslator extends Qu
         return columns;
     }
 
-    <T> List<ColumnDescriptor> appendIdColumns(
-            final List<ColumnDescriptor> columns,
-            SelectQuery<T> query) {
+    <T> List<ColumnDescriptor> appendIdColumns(final List<ColumnDescriptor> columns, SelectQuery<T> query) {
 
         Set<ColumnTracker> skipSet = new HashSet<ColumnTracker>();
 
@@ -534,30 +507,24 @@ public class SelectTranslator extends Qu
         DbEntity dbEntity = oe.getDbEntity();
         for (ObjAttribute attribute : oe.getPrimaryKeys()) {
 
-            // synthetic objattributes can't reliably lookup their DbAttribute, so do
+            // synthetic objattributes can't reliably lookup their DbAttribute,
+            // so do
             // it manually..
-            DbAttribute dbAttribute = (DbAttribute) dbEntity.getAttribute(attribute
-                    .getDbAttributeName());
+            DbAttribute dbAttribute = (DbAttribute) dbEntity.getAttribute(attribute.getDbAttributeName());
             appendColumn(columns, attribute, dbAttribute, skipSet, null);
         }
 
         return columns;
     }
 
-    private void appendColumn(
-            List<ColumnDescriptor> columns,
-            ObjAttribute objAttribute,
-            DbAttribute attribute,
-            Set<ColumnTracker> skipSet,
-            String label) {
+    private void appendColumn(List<ColumnDescriptor> columns, ObjAttribute objAttribute, DbAttribute attribute,
+            Set<ColumnTracker> skipSet, String label) {
 
         String alias = getCurrentAlias();
         if (skipSet.add(new ColumnTracker(alias, attribute))) {
 
-            ColumnDescriptor column = (objAttribute != null) ? new ColumnDescriptor(
-                    objAttribute,
-                    attribute,
-                    alias) : new ColumnDescriptor(attribute, alias);
+            ColumnDescriptor column = (objAttribute != null) ? new ColumnDescriptor(objAttribute, attribute, alias)
+                    : new ColumnDescriptor(attribute, alias);
 
             if (label != null) {
                 column.setDataRowKey(label);
@@ -565,11 +532,11 @@ public class SelectTranslator extends Qu
 
             columns.add(column);
 
-            // TODO: andrus, 5/7/2006 - replace 'columns' collection with this map, as it
+            // TODO: andrus, 5/7/2006 - replace 'columns' collection with this
+            // map, as it
             // is redundant
             defaultAttributesByColumn.put(column, objAttribute);
-        }
-        else if (objAttribute != null) {
+        } else if (objAttribute != null) {
 
             // record ObjAttribute override
             for (ColumnDescriptor column : columns) {
@@ -605,10 +572,7 @@ public class SelectTranslator extends Qu
      * @since 3.0
      */
     @Override
-    public void dbRelationshipAdded(
-            DbRelationship relationship,
-            JoinType joinType,
-            String joinSplitAlias) {
+    public void dbRelationshipAdded(DbRelationship relationship, JoinType joinType, String joinSplitAlias) {
         if (relationship.isToMany()) {
             forcingDistinct = true;
         }
@@ -638,19 +602,14 @@ public class SelectTranslator extends Qu
         public boolean equals(Object object) {
             if (object instanceof ColumnTracker) {
                 ColumnTracker other = (ColumnTracker) object;
-                return new EqualsBuilder().append(alias, other.alias).append(
-                        attribute,
-                        other.attribute).isEquals();
+                return new EqualsBuilder().append(alias, other.alias).append(attribute, other.attribute).isEquals();
             }
             return false;
         }
 
         @Override
         public int hashCode() {
-            return new HashCodeBuilder(31, 5)
-                    .append(alias)
-                    .append(attribute)
-                    .toHashCode();
+            return new HashCodeBuilder(31, 5).append(alias).append(attribute).toHashCode();
         }
 
     }

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -44,15 +44,9 @@ public class UpdateBatchQueryBuilder ext
     @Override
     public String createSqlString(BatchQuery batch) throws IOException {
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) batch;
-        boolean status;
-        if(batch.getDbEntity().getDataMap()!=null && batch.getDbEntity().getDataMap().isQuotingSQLIdentifiers()){ 
-            status= true;
-        } else {
-            status = false;
-        }
 
-        QuotingStrategy strategy =  getAdapter().getQuotingStrategy(status);
-        
+        QuotingStrategy strategy = getAdapter().getQuotingStrategy();
+
         List<DbAttribute> qualifierAttributes = updateBatch.getQualifierAttributes();
         List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes();
 
@@ -67,7 +61,7 @@ public class UpdateBatchQueryBuilder ext
             }
 
             DbAttribute attribute = updatedDbAttributes.get(i);
-            query.append(strategy.quotedIdentifier(attribute.getName()));
+            query.append(strategy.quotedName(attribute));
             query.append(" = ?");
         }
 
@@ -91,8 +85,7 @@ public class UpdateBatchQueryBuilder ext
      * Binds BatchQuery parameters to the PreparedStatement.
      */
     @Override
-    public void bindParameters(PreparedStatement statement, BatchQuery query)
-            throws SQLException, Exception {
+    public void bindParameters(PreparedStatement statement, BatchQuery query) throws SQLException, Exception {
 
         UpdateBatchQuery updateBatch = (UpdateBatchQuery) query;
         List<DbAttribute> qualifierAttributes = updateBatch.getQualifierAttributes();
@@ -104,12 +97,7 @@ public class UpdateBatchQueryBuilder ext
             Object value = query.getValue(i);
 
             DbAttribute attribute = updatedDbAttributes.get(i);
-            adapter.bindParameter(
-                    statement,
-                    value,
-                    parameterIndex++,
-                    attribute.getType(),
-                    attribute.getScale());
+            adapter.bindParameter(statement, value, parameterIndex++, attribute.getType(), attribute.getScale());
         }
 
         for (int i = 0; i < qualifierAttributes.size(); i++) {
@@ -121,12 +109,7 @@ public class UpdateBatchQueryBuilder ext
                 continue;
             }
 
-            adapter.bindParameter(
-                    statement,
-                    value,
-                    parameterIndex++,
-                    attribute.getType(),
-                    attribute.getScale());
+            adapter.bindParameter(statement, value, parameterIndex++, attribute.getType(), attribute.getScale());
         }
     }
 }

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -198,7 +198,18 @@ public class AutoAdapter implements DbAd
         getAdapter().createTableAppendColumn(sqlBuffer, column);
     }
 
+    /**
+     * @deprecated since 3.2
+     */
+    @Deprecated
     public QuotingStrategy getQuotingStrategy(boolean isQuoteStrategy) {
         return getAdapter().getQuotingStrategy(isQuoteStrategy);
     }
+    
+    /**
+     * @since 3.2
+     */
+    public QuotingStrategy getQuotingStrategy() {
+        return getAdapter().getQuotingStrategy();
+    }
 }

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -181,6 +181,15 @@ public interface DbAdapter {
 
     /**
      * @since 3.0
+     * @deprecated since 3.2 use {@link #getQuotingStrategy()}.
      */
+    @Deprecated
     QuotingStrategy getQuotingStrategy(boolean needQuotes);
+    
+    /**
+     * Returns SQL identifier quoting strategy object 
+     * 
+     * @since 3.2
+     */
+    QuotingStrategy getQuotingStrategy();
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/DefaultQuotingStrategy.java Sun Feb 24 11:53:37 2013
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.cayenne.dba;
 
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbJoin;
+import org.apache.cayenne.map.Entity;
 
 /**
  * @since 3.2 this is a top-level class.
@@ -38,25 +42,53 @@ class DefaultQuotingStrategy implements 
      */
     @Deprecated
     public String quoteString(String name) {
-        return quotedIdentifier(name);
+        return quotedIdentifier((DataMap) null, name);
     }
-    
+
     @Deprecated
     public String quoteFullyQualifiedName(DbEntity entity) {
-       return quotedFullyQualifiedName(entity);
+        return quotedFullyQualifiedName(entity);
     }
 
     public String quotedFullyQualifiedName(DbEntity entity) {
-        return quotedIdentifier(entity.getCatalog(), entity.getSchema(), entity.getName());
+        return quotedIdentifier(entity.getDataMap(), entity.getCatalog(), entity.getSchema(), entity.getName());
+    }
+
+    public String quotedName(DbAttribute attribute) {
+        return quotedIdentifier(attribute.getEntity().getDataMap(), attribute.getName());
     }
 
-    public String quotedIdentifier(String... fqnParts) {
+    public String quotedSourceName(DbJoin join) {
+        DataMap dataMap = join.getSource().getEntity().getDataMap();
+        return quotedIdentifier(dataMap, join.getSourceName());
+    }
+
+    public String quotedTargetName(DbJoin join) {
+        DataMap dataMap = join.getTarget().getEntity().getDataMap();
+        return quotedIdentifier(dataMap, join.getTargetName());
+    }
+
+    public String quotedIdentifier(Entity entity, String... identifierParts) {
+        return quotedIdentifier(entity.getDataMap(), identifierParts);
+    }
+
+    public String quotedIdentifier(DataMap dataMap, String... identifierParts) {
+
+        String startQuote, endQuote;
+
+        if (dataMap != null && dataMap.isQuotingSQLIdentifiers()) {
+            startQuote = this.startQuote;
+            endQuote = this.endQuote;
+        } else {
+            startQuote = "";
+            endQuote = "";
+        }
 
         StringBuilder buffer = new StringBuilder();
 
-        for (String part : fqnParts) {
-            
-            if(part == null) {
+        for (String part : identifierParts) {
+
+            if (part == null) {
                 continue;
             }
 

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -67,8 +67,7 @@ public class JdbcAdapter implements DbAd
     final static String DEFAULT_IDENTIFIERS_END_QUOTE = "\"";
 
     private PkGenerator pkGenerator;
-    private final QuotingStrategy noQuotingStrategy;
-    private QuotingStrategy quotingStrategy;
+    protected QuotingStrategy quotingStrategy;
 
     protected TypesHandler typesHandler;
     protected ExtendedTypeMap extendedTypes;
@@ -114,8 +113,6 @@ public class JdbcAdapter implements DbAd
             @Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
             @Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories) {
 
-        this.noQuotingStrategy = new NoQuotingStrategy();
-
         // init defaults
         this.setSupportsBatchUpdates(false);
         this.setSupportsUniqueConstraints(true);
@@ -268,10 +265,9 @@ public class JdbcAdapter implements DbAd
      * @since 3.0
      */
     public Collection<String> dropTableStatements(DbEntity table) {
-        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
 
         StringBuilder buf = new StringBuilder("DROP TABLE ");
-        buf.append(context.quotedFullyQualifiedName(table));
+        buf.append(quotingStrategy.quotedFullyQualifiedName(table));
 
         return Collections.singleton(buf.toString());
     }
@@ -281,11 +277,10 @@ public class JdbcAdapter implements DbAd
      * corresponding to <code>ent</code> parameter.
      */
     public String createTable(DbEntity entity) {
-        boolean status = (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers());
-        QuotingStrategy context = getQuotingStrategy(status);
+
         StringBuffer sqlBuffer = new StringBuffer();
         sqlBuffer.append("CREATE TABLE ");
-        sqlBuffer.append(context.quotedFullyQualifiedName(entity));
+        sqlBuffer.append(quotingStrategy.quotedFullyQualifiedName(entity));
 
         sqlBuffer.append(" (");
         // columns
@@ -321,12 +316,12 @@ public class JdbcAdapter implements DbAd
      * @since 1.2
      */
     protected void createTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity) {
-        boolean status = (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers());
-        QuotingStrategy context = getQuotingStrategy(status);
+
         Iterator<DbAttribute> pkit = entity.getPrimaryKeys().iterator();
         if (pkit.hasNext()) {
             sqlBuffer.append(", PRIMARY KEY (");
             boolean firstPk = true;
+
             while (pkit.hasNext()) {
                 if (firstPk)
                     firstPk = false;
@@ -335,7 +330,7 @@ public class JdbcAdapter implements DbAd
 
                 DbAttribute at = pkit.next();
 
-                sqlBuffer.append(context.quotedIdentifier(at.getName()));
+                sqlBuffer.append(quotingStrategy.quotedName(at));
             }
             sqlBuffer.append(')');
         }
@@ -347,9 +342,7 @@ public class JdbcAdapter implements DbAd
      * @since 1.2
      */
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
-        boolean status = ((column.getEntity().getDataMap() != null) && column.getEntity().getDataMap()
-                .isQuotingSQLIdentifiers());
-        QuotingStrategy context = getQuotingStrategy(status);
+
         String[] types = externalTypesForJdbcType(column.getType());
         if (types == null || types.length == 0) {
             String entityName = column.getEntity() != null ? ((DbEntity) column.getEntity()).getFullyQualifiedName()
@@ -359,7 +352,7 @@ public class JdbcAdapter implements DbAd
         }
 
         String type = types[0];
-        sqlBuffer.append(context.quotedIdentifier(column.getName()));
+        sqlBuffer.append(quotingStrategy.quotedName(column));
         sqlBuffer.append(' ').append(type);
 
         // append size and precision (if applicable)s
@@ -394,8 +387,6 @@ public class JdbcAdapter implements DbAd
      * @since 1.1
      */
     public String createUniqueConstraint(DbEntity source, Collection<DbAttribute> columns) {
-        boolean status = (source.getDataMap() != null && source.getDataMap().isQuotingSQLIdentifiers());
-        QuotingStrategy context = getQuotingStrategy(status);
 
         if (columns == null || columns.isEmpty()) {
             throw new CayenneRuntimeException("Can't create UNIQUE constraint - no columns specified.");
@@ -404,17 +395,17 @@ public class JdbcAdapter implements DbAd
         StringBuilder buf = new StringBuilder();
 
         buf.append("ALTER TABLE ");
-        buf.append(context.quotedFullyQualifiedName(source));
+        buf.append(quotingStrategy.quotedFullyQualifiedName(source));
         buf.append(" ADD UNIQUE (");
 
         Iterator<DbAttribute> it = columns.iterator();
         DbAttribute first = it.next();
-        buf.append(context.quotedIdentifier(first.getName()));
+        buf.append(quotingStrategy.quotedName(first));
 
         while (it.hasNext()) {
             DbAttribute next = it.next();
             buf.append(", ");
-            buf.append(context.quotedIdentifier(next.getName()));
+            buf.append(quotingStrategy.quotedName(next));
         }
 
         buf.append(")");
@@ -429,14 +420,12 @@ public class JdbcAdapter implements DbAd
     public String createFkConstraint(DbRelationship rel) {
 
         DbEntity source = (DbEntity) rel.getSourceEntity();
-        boolean status = (source.getDataMap() != null && source.getDataMap().isQuotingSQLIdentifiers());
-        QuotingStrategy context = getQuotingStrategy(status);
         StringBuilder buf = new StringBuilder();
         StringBuilder refBuf = new StringBuilder();
 
         buf.append("ALTER TABLE ");
 
-        buf.append(context.quotedFullyQualifiedName(source));
+        buf.append(quotingStrategy.quotedFullyQualifiedName(source));
         buf.append(" ADD FOREIGN KEY (");
 
         boolean first = true;
@@ -448,13 +437,13 @@ public class JdbcAdapter implements DbAd
             } else
                 first = false;
 
-            buf.append(context.quotedIdentifier(join.getSourceName()));
-            refBuf.append(context.quotedIdentifier(join.getTargetName()));
+            buf.append(quotingStrategy.quotedSourceName(join));
+            refBuf.append(quotingStrategy.quotedTargetName(join));
         }
 
         buf.append(") REFERENCES ");
 
-        buf.append(context.quotedFullyQualifiedName((DbEntity) rel.getTargetEntity()));
+        buf.append(quotingStrategy.quotedFullyQualifiedName((DbEntity) rel.getTargetEntity()));
 
         buf.append(" (").append(refBuf.toString()).append(')');
         return buf.toString();
@@ -586,9 +575,18 @@ public class JdbcAdapter implements DbAd
 
     /**
      * @since 3.0
+     * @deprecated since 3.2 use {@link #getQuotingStrategy()}.
      */
+    @Deprecated
     public QuotingStrategy getQuotingStrategy(boolean needQuotes) {
-        return (needQuotes) ? quotingStrategy : noQuotingStrategy;
+        return getQuotingStrategy();
+    }
+
+    /**
+     * @since 3.2
+     */
+    public QuotingStrategy getQuotingStrategy() {
+        return quotingStrategy;
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/QuotingStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/QuotingStrategy.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/QuotingStrategy.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/QuotingStrategy.java Sun Feb 24 11:53:37 2013
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.cayenne.dba;
 
+import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbJoin;
+import org.apache.cayenne.map.Entity;
 
 /**
  * @since 3.0
@@ -28,7 +32,7 @@ public interface QuotingStrategy {
     /**
      * Returns a properly quoted identifier.
      * 
-     * @deprecated use {@link #quotedIdentifier(String...)}
+     * @deprecated since 3.2
      */
     @Deprecated
     String quoteString(String identifier);
@@ -51,11 +55,28 @@ public interface QuotingStrategy {
     String quotedFullyQualifiedName(DbEntity entity);
 
     /**
-     * Builds a dot-separated qualifier, inclosing parts in quotations according
-     * to this strategy algorithm. Any of the parts can be null, in which case
-     * it will be skipped.
      * 
      * @since 3.2
      */
-    String quotedIdentifier(String... identifierParts);
+    String quotedName(DbAttribute attribute);
+
+    /**
+     * @since 3.2
+     */
+    String quotedSourceName(DbJoin join);
+
+    /**
+     * @since 3.2
+     */
+    String quotedTargetName(DbJoin join);
+
+    /**
+     * @since 3.2
+     */
+    String quotedIdentifier(Entity entity, String... identifierParts);
+    
+    /**
+     * @since 3.2
+     */
+    String quotedIdentifier(DataMap dataMap, String... identifierParts);
 }

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -98,14 +98,8 @@ public class DB2Adapter extends JdbcAdap
      */
     @Override
     public String createTable(DbEntity ent) {
-        boolean status;
-        if (ent.getDataMap() != null && ent.getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
-        QuotingStrategy context = getQuotingStrategy(status);
+     
+        QuotingStrategy context = getQuotingStrategy();
 
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
@@ -144,7 +138,7 @@ public class DB2Adapter extends JdbcAdap
             }
 
             String type = types[0];
-            buf.append(context.quotedIdentifier(at.getName())).append(' ').append(type);
+            buf.append(context.quotedName(at)).append(' ').append(type);
 
             // append size and precision (if applicable)
             if (TypesMapping.supportsLength(at.getType())) {
@@ -193,7 +187,7 @@ public class DB2Adapter extends JdbcAdap
                     buf.append(", ");
 
                 DbAttribute at = pkit.next();
-                buf.append(context.quotedIdentifier(at.getName()));
+                buf.append(context.quotedName(at));
             }
             buf.append(')');
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2MergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2MergerFactory.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2MergerFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2MergerFactory.java Sun Feb 24 11:53:37 2013
@@ -41,7 +41,7 @@ public class DB2MergerFactory extends Me
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quotedFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
+                sqlBuffer.append(context.quotedName(columnNew));
                 sqlBuffer.append(" SET DATA TYPE ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/db2/DB2PkGenerator.java Sun Feb 24 11:53:37 2013
@@ -31,7 +31,6 @@ import org.apache.cayenne.CayenneRuntime
 import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.dba.JdbcPkGenerator;
-import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
 
@@ -177,17 +176,10 @@ public class DB2PkGenerator extends Jdbc
      * Returns default sequence name for DbEntity.
      */
     protected String sequenceName(DbEntity entity) {
-        boolean status;
-        if (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        } else {
-            status = false;
-        }
-        QuotingStrategy context = getAdapter().getQuotingStrategy(status);
         String entName = entity.getName();
         String seqName = _SEQUENCE_PREFIX + entName;
 
-        return context.quotedIdentifier(entity.getCatalog(), entity.getSchema(), seqName);
+        return adapter.getQuotingStrategy().quotedIdentifier(entity, entity.getCatalog(), entity.getSchema(), seqName);
     }
 
     /**

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -37,7 +37,6 @@ import org.apache.cayenne.configuration.
 import org.apache.cayenne.configuration.RuntimeProperties;
 import org.apache.cayenne.dba.JdbcAdapter;
 import org.apache.cayenne.dba.PkGenerator;
-import org.apache.cayenne.dba.QuotingStrategy;
 import org.apache.cayenne.dba.TypesMapping;
 import org.apache.cayenne.di.Inject;
 import org.apache.cayenne.map.DbAttribute;
@@ -110,15 +109,6 @@ public class DerbyAdapter extends JdbcAd
     @Override
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
 
-        boolean status;
-        if ((column.getEntity().getDataMap() != null)
-                && 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
@@ -158,7 +148,7 @@ public class DerbyAdapter extends JdbcAd
         // note that max length for types like XYZ FOR BIT DATA must be entered in the
         // middle of type name, e.g. VARCHAR (100) FOR BIT DATA.
 
-        sqlBuffer.append(context.quotedIdentifier(column.getName()));
+        sqlBuffer.append(quotingStrategy.quotedName(column));
 
         sqlBuffer.append(' ');
         if (length.length() > 0 && type.endsWith(FOR_BIT_DATA_SUFFIX)) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/derby/DerbyMergerFactory.java Sun Feb 24 11:53:37 2013
@@ -47,7 +47,7 @@ public class DerbyMergerFactory extends 
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quotedFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
+                sqlBuffer.append(context.quotedName(columnNew));
                 sqlBuffer.append(" SET DATA TYPE ");
             }
         };
@@ -60,13 +60,11 @@ public class DerbyMergerFactory extends 
             @Override
             public List<String> createSql(DbAdapter adapter) {
                 StringBuilder sqlBuffer = new StringBuilder();
-                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
-                        .getDataMap()
-                        .isQuotingSQLIdentifiers());
+                QuotingStrategy context = adapter.getQuotingStrategy();
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
+                sqlBuffer.append(context.quotedName(getColumn()));
                 sqlBuffer.append(" NOT NULL");
 
                 return Collections.singletonList(sqlBuffer.toString());
@@ -82,13 +80,11 @@ public class DerbyMergerFactory extends 
             @Override
             public List<String> createSql(DbAdapter adapter) {
                 StringBuilder sqlBuffer = new StringBuilder();
-                QuotingStrategy context = adapter.getQuotingStrategy(getEntity()
-                        .getDataMap()
-                        .isQuotingSQLIdentifiers());
+                QuotingStrategy context = adapter.getQuotingStrategy();
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
+                sqlBuffer.append(context.quotedName(getColumn()));
                 sqlBuffer.append(" NULL");
 
                 return Collections.singletonList(sqlBuffer.toString());

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=1449462&r1=1449461&r2=1449462&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 Sun Feb 24 11:53:37 2013
@@ -104,14 +104,7 @@ public class FrontBaseAdapter extends Jd
      */
     @Override
     public String createTable(DbEntity ent) {
-        boolean status;
-        if (ent.getDataMap() != null && ent.getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
-        QuotingStrategy context = getQuotingStrategy(status);
+        QuotingStrategy context = getQuotingStrategy();
         StringBuilder buf = new StringBuilder();
         buf.append("CREATE TABLE ");
         buf.append(context.quotedFullyQualifiedName(ent));
@@ -148,7 +141,7 @@ public class FrontBaseAdapter extends Jd
             }
 
             String type = types[0];
-            buf.append(context.quotedIdentifier(at.getName())).append(' ').append(type);
+            buf.append(context.quotedName(at)).append(' ').append(type);
 
             // Mapping LONGVARCHAR without length creates a column with length "1" which
             // is definitely not what we want...so just use something very large (1Gb seems
@@ -208,7 +201,7 @@ public class FrontBaseAdapter extends Jd
                     buf.append(", ");
 
                 DbAttribute at = pkit.next();
-                buf.append(context.quotedIdentifier(at.getName()));
+                buf.append(quotingStrategy.quotedName(at));
             }
             buf.append(')');
         }
@@ -221,14 +214,8 @@ public class FrontBaseAdapter extends Jd
      */
     @Override
     public Collection<String> dropTableStatements(DbEntity table) {
-        boolean status;
-        if (table.getDataMap() != null && table.getDataMap().isQuotingSQLIdentifiers()) {
-            status = true;
-        }
-        else {
-            status = false;
-        }
-        QuotingStrategy context = getQuotingStrategy(status);
+
+        QuotingStrategy context = getQuotingStrategy();
         StringBuffer buf = new StringBuffer("DROP TABLE ");
         buf.append(context.quotedFullyQualifiedName(table));
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java?rev=1449462&r1=1449461&r2=1449462&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/h2/H2MergerFactory.java Sun Feb 24 11:53:37 2013
@@ -39,9 +39,7 @@ import org.apache.cayenne.merge.SetPrima
 public class H2MergerFactory extends MergerFactory {
 
     @Override
-    public MergerToken createSetColumnTypeToDb(
-            final DbEntity entity,
-            DbAttribute columnOriginal,
+    public MergerToken createSetColumnTypeToDb(final DbEntity entity, DbAttribute columnOriginal,
             final DbAttribute columnNew) {
         return new SetColumnTypeToDb(entity, columnOriginal, columnNew) {
 
@@ -50,7 +48,7 @@ public class H2MergerFactory extends Mer
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quotedFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
+                sqlBuffer.append(context.quotedName(columnNew));
                 sqlBuffer.append(" ");
             }
         };
@@ -75,26 +73,15 @@ public class H2MergerFactory extends Mer
 
         };
     }
-    
+
     @Override
-    public MergerToken createSetPrimaryKeyToDb(
-            DbEntity entity,
-            Collection<DbAttribute> primaryKeyOriginal,
-            Collection<DbAttribute> primaryKeyNew,
-            String detectedPrimaryKeyName) {
-        return new SetPrimaryKeyToDb(
-                entity,
-                primaryKeyOriginal,
-                primaryKeyNew,
-                detectedPrimaryKeyName) {
+    public MergerToken createSetPrimaryKeyToDb(DbEntity entity, Collection<DbAttribute> primaryKeyOriginal,
+            Collection<DbAttribute> primaryKeyNew, String detectedPrimaryKeyName) {
+        return new SetPrimaryKeyToDb(entity, primaryKeyOriginal, primaryKeyNew, detectedPrimaryKeyName) {
 
             @Override
-            protected void appendDropOriginalPrimaryKeySQL(
-                    DbAdapter adapter,
-                    List<String> sqls) {
-                sqls.add("ALTER TABLE "
-                        + getQuotingStrategy(adapter)
-                                .quotedFullyQualifiedName(getEntity())
+            protected void appendDropOriginalPrimaryKeySQL(DbAdapter adapter, List<String> sqls) {
+                sqls.add("ALTER TABLE " + adapter.getQuotingStrategy().quotedFullyQualifiedName(getEntity())
                         + " DROP PRIMARY KEY");
             }
 



Mime
View raw message