cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1409947 [2/2] - 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 Thu, 15 Nov 2012 19:40:15 GMT
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=1409947&r1=1409946&r2=1409947&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
Thu Nov 15 19:40:07 2012
@@ -55,17 +55,19 @@ import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLAction;
 
 /**
- * DbAdapter implementation for <a href="http://www.mysql.com">MySQL RDBMS</a>.
<h3>
+ * DbAdapter implementation for <a href="http://www.mysql.com">MySQL RDBMS</a>.
+ * <h3>
  * Foreign Key Constraint Handling</h3>
  * <p>
- * Foreign key constraints are supported by InnoDB engine and NOT supported by MyISAM
- * engine. This adapter by default assumes MyISAM, so
- * {@link org.apache.cayenne.dba.JdbcAdapter#supportsFkConstraints()} will return false.
- * Users can manually change this by calling <em>setSupportsFkConstraints(true)</em>
or
- * better by using an {@link org.apache.cayenne.dba.AutoAdapter}, i.e. not entering the
- * adapter name at all for the DataNode, letting Cayenne guess it in runtime. In the later
- * case Cayenne will check the <em>table_type</em> MySQL variable to detect whether
InnoDB
- * is the default, and configure the adapter accordingly.
+ * Foreign key constraints are supported by InnoDB engine and NOT supported by
+ * MyISAM engine. This adapter by default assumes MyISAM, so
+ * {@link org.apache.cayenne.dba.JdbcAdapter#supportsFkConstraints()} will
+ * return false. Users can manually change this by calling
+ * <em>setSupportsFkConstraints(true)</em> or better by using an
+ * {@link org.apache.cayenne.dba.AutoAdapter}, i.e. not entering the adapter
+ * name at all for the DataNode, letting Cayenne guess it in runtime. In the
+ * later case Cayenne will check the <em>table_type</em> MySQL variable to
+ * detect whether InnoDB is the default, and configure the adapter accordingly.
  * <h3>Sample Connection Settings</h3>
  * <ul>
  * <li>Adapter name: org.apache.cayenne.dba.mysql.MySQLAdapter</li>
@@ -106,7 +108,7 @@ public class MySQLAdapter extends JdbcAd
         this.identifiersStartQuote = MYSQL_QUOTE_SQL_IDENTIFIERS_CHAR_START;
         this.identifiersEndQuote = MYSQL_QUOTE_SQL_IDENTIFIERS_CHAR_END;
     }
-    
+
     @Override
     public QualifierTranslator getQualifierTranslator(QueryAssembler queryAssembler) {
         QualifierTranslator translator = new MySQLQualifierTranslator(queryAssembler);
@@ -121,8 +123,7 @@ public class MySQLAdapter extends JdbcAd
      */
     @Override
     public SQLAction getAction(Query query, DataNode node) {
-        return query
-                .createSQLAction(new MySQLActionBuilder(this, node.getEntityResolver()));
+        return query.createSQLAction(new MySQLActionBuilder(this, node.getEntityResolver()));
     }
 
     /**
@@ -130,22 +131,20 @@ public class MySQLAdapter extends JdbcAd
      */
     @Override
     public Collection<String> dropTableStatements(DbEntity table) {
-        // note that CASCADE is a noop as of MySQL 5.0, so we have to use FK checks
+        // 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 = getQuotingStrategy(table
-                .getDataMap()
-                .isQuotingSQLIdentifiers());
+        QuotingStrategy context = getQuotingStrategy(table.getDataMap().isQuotingSQLIdentifiers());
         buf.append(context.quoteFullyQualifiedName(table));
 
-        return Arrays.asList("SET FOREIGN_KEY_CHECKS=0", "DROP TABLE IF EXISTS "
-                + buf.toString()
-                + " CASCADE", "SET FOREIGN_KEY_CHECKS=1");
+        return Arrays.asList("SET FOREIGN_KEY_CHECKS=0", "DROP TABLE IF EXISTS " + buf.toString()
+ " CASCADE",
+                "SET FOREIGN_KEY_CHECKS=1");
     }
 
     /**
-     * Installs appropriate ExtendedTypes used as converters for passing values between
-     * JDBC and Java layers.
+     * Installs appropriate ExtendedTypes used as converters for passing values
+     * between JDBC and Java layers.
      */
     @Override
     protected void configureExtendedTypes(ExtendedTypeMap map) {
@@ -160,43 +159,32 @@ public class MySQLAdapter extends JdbcAd
     }
 
     @Override
-    public DbAttribute buildAttribute(
-            String name,
-            String typeName,
-            int type,
-            int size,
-            int precision,
+    public DbAttribute buildAttribute(String name, String typeName, int type, int size, int
precision,
             boolean allowNulls) {
 
         if (typeName != null) {
             typeName = typeName.toLowerCase();
         }
 
-        // all LOB types are returned by the driver as OTHER... must remap them manually
+        // all LOB types are returned by the driver as OTHER... must remap them
+        // manually
         // (at least on MySQL 3.23)
         if (type == Types.OTHER) {
             if ("longblob".equals(typeName)) {
                 type = Types.BLOB;
-            }
-            else if ("mediumblob".equals(typeName)) {
+            } else if ("mediumblob".equals(typeName)) {
                 type = Types.BLOB;
-            }
-            else if ("blob".equals(typeName)) {
+            } else if ("blob".equals(typeName)) {
                 type = Types.BLOB;
-            }
-            else if ("tinyblob".equals(typeName)) {
+            } else if ("tinyblob".equals(typeName)) {
                 type = Types.VARBINARY;
-            }
-            else if ("longtext".equals(typeName)) {
+            } else if ("longtext".equals(typeName)) {
                 type = Types.CLOB;
-            }
-            else if ("mediumtext".equals(typeName)) {
+            } else if ("mediumtext".equals(typeName)) {
                 type = Types.CLOB;
-            }
-            else if ("text".equals(typeName)) {
+            } else if ("text".equals(typeName)) {
                 type = Types.CLOB;
-            }
-            else if ("tinytext".equals(typeName)) {
+            } else if ("tinytext".equals(typeName)) {
                 type = Types.VARCHAR;
             }
         }
@@ -204,12 +192,12 @@ public class MySQLAdapter extends JdbcAd
         else if (typeName != null && typeName.endsWith(" unsigned")) {
             // per
             // http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-type-conversions.html
-            if (typeName.equals("int unsigned")
-                    || typeName.equals("integer unsigned")
+            if (typeName.equals("int unsigned") || typeName.equals("integer unsigned")
                     || typeName.equals("mediumint unsigned")) {
                 type = Types.BIGINT;
             }
-            // BIGINT UNSIGNED maps to BigInteger according to MySQL docs, but there is no
+            // BIGINT UNSIGNED maps to BigInteger according to MySQL docs, but
+            // there is no
             // JDBC mapping for BigInteger
         }
 
@@ -217,8 +205,9 @@ public class MySQLAdapter extends JdbcAd
     }
 
     /**
-     * Creates and returns a primary key generator. Overrides superclass implementation to
-     * return an instance of MySQLPkGenerator that does the correct table locking.
+     * Creates and returns a primary key generator. Overrides superclass
+     * implementation to return an instance of MySQLPkGenerator that does the
+     * correct table locking.
      */
     @Override
     protected PkGenerator createPkGenerator() {
@@ -230,15 +219,14 @@ public class MySQLAdapter extends JdbcAd
      */
     @Override
     protected EJBQLTranslatorFactory createEJBQLTranslatorFactory() {
-        JdbcEJBQLTranslatorFactory translatorFactory = 
-                new MySQLEJBQLTranslatorFactory();
+        JdbcEJBQLTranslatorFactory translatorFactory = new MySQLEJBQLTranslatorFactory();
         translatorFactory.setCaseInsensitive(caseInsensitiveCollations);
         return translatorFactory;
     }
 
     /**
-     * Overrides super implementation to explicitly set table engine to InnoDB if FK
-     * constraints are supported by this adapter.
+     * Overrides super implementation to explicitly set table engine to InnoDB
+     * if FK constraints are supported by this adapter.
      */
     @Override
     public String createTable(DbEntity entity) {
@@ -252,9 +240,9 @@ public class MySQLAdapter extends JdbcAd
     }
 
     /**
-     * Customizes PK clause semantics to ensure that generated columns are in the
-     * beginning of the PK definition, as this seems to be a requirement for InnoDB
-     * tables.
+     * Customizes PK clause semantics to ensure that generated columns are in
+     * the beginning of the PK definition, as this seems to be a requirement for
+     * InnoDB tables.
      * 
      * @since 1.2
      */
@@ -264,8 +252,7 @@ public class MySQLAdapter extends JdbcAd
         boolean status;
         if (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers())
{
             status = true;
-        }
-        else {
+        } else {
             status = false;
         }
         QuotingStrategy context = getQuotingStrategy(status);
@@ -285,33 +272,29 @@ public class MySQLAdapter extends JdbcAd
                     sqlBuffer.append(", ");
 
                 DbAttribute at = pkit.next();
-                sqlBuffer.append(context.quoteString(at.getName()));
+                sqlBuffer.append(context.quotedIdentifier(at.getName()));
             }
             sqlBuffer.append(')');
         }
 
         // if FK constraints are supported, we must add indices to all FKs
-        // Note that according to MySQL docs, FK indexes are created automatically when
+        // Note that according to MySQL docs, FK indexes are created
+        // automatically when
         // constraint is defined, starting at MySQL 4.1.2
         if (supportsFkConstraints) {
             for (Relationship r : entity.getRelationships()) {
                 DbRelationship relationship = (DbRelationship) r;
-                if (relationship.getJoins().size() > 0
-                        && relationship.isToPK()
-                        && !relationship.isToDependentPK()) {
+                if (relationship.getJoins().size() > 0 && relationship.isToPK()
&& !relationship.isToDependentPK()) {
 
                     sqlBuffer.append(", KEY (");
 
-                    Iterator<DbAttribute> columns = relationship
-                            .getSourceAttributes()
-                            .iterator();
+                    Iterator<DbAttribute> columns = relationship.getSourceAttributes().iterator();
                     DbAttribute column = columns.next();
-                    sqlBuffer.append(context.quoteString(column.getName()));
+                    sqlBuffer.append(context.quotedIdentifier(column.getName()));
 
                     while (columns.hasNext()) {
                         column = columns.next();
-                        sqlBuffer.append(", ").append(
-                                context.quoteString(column.getName()));
+                        sqlBuffer.append(", ").append(context.quotedIdentifier(column.getName()));
                     }
 
                     sqlBuffer.append(")");
@@ -321,33 +304,28 @@ public class MySQLAdapter extends JdbcAd
     }
 
     /**
-     * Appends AUTO_INCREMENT clause to the column definition for generated columns.
+     * Appends AUTO_INCREMENT clause to the column definition for generated
+     * columns.
      */
     @Override
     public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
         boolean status;
-        if ((column.getEntity().getDataMap() != null)
-                && column.getEntity().getDataMap().isQuotingSQLIdentifiers()) {
+        if ((column.getEntity().getDataMap() != null) && column.getEntity().getDataMap().isQuotingSQLIdentifiers())
{
             status = true;
-        }
-        else {
+        } 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
-                    .getEntity()).getFullyQualifiedName() : "<null>";
-            throw new CayenneRuntimeException("Undefined type for attribute '"
-                    + entityName
-                    + "."
-                    + column.getName()
-                    + "': "
-                    + column.getType());
+            String entityName = column.getEntity() != null ? ((DbEntity) column.getEntity()).getFullyQualifiedName()
+                    : "<null>";
+            throw new CayenneRuntimeException("Undefined type for attribute '" + entityName
+ "." + column.getName()
+                    + "': " + column.getType());
         }
 
         String type = types[0];
-        sqlBuffer.append(context.quoteString(column.getName()));
+        sqlBuffer.append(context.quotedIdentifier(column.getName()));
         sqlBuffer.append(' ').append(type);
 
         // append size and precision (if applicable)s
@@ -389,8 +367,7 @@ public class MySQLAdapter extends JdbcAd
         public int compare(DbAttribute a1, DbAttribute a2) {
             if (a1.isGenerated() != a2.isGenerated()) {
                 return a1.isGenerated() ? -1 : 1;
-            }
-            else {
+            } else {
                 return a1.getName().compareTo(a2.getName());
             }
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/mysql/MySQLMergerFactory.java
Thu Nov 15 19:40:07 2012
@@ -54,7 +54,7 @@ public class MySQLMergerFactory extends 
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" CHANGE ");
-                sqlBuffer.append(context.quoteString(getColumn().getName()));
+                sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
                 sqlBuffer.append(" ");
                 adapter.createTableAppendColumn(sqlBuffer, column);
 
@@ -81,7 +81,7 @@ public class MySQLMergerFactory extends 
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" CHANGE ");
-                sqlBuffer.append(context.quoteString(getColumn().getName()));
+                sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
                 sqlBuffer.append(" ");
                 adapter.createTableAppendColumn(sqlBuffer, column);
 
@@ -105,7 +105,7 @@ public class MySQLMergerFactory extends 
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(context.quoteString(columnNew.getName()));
+                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
 

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=1409947&r1=1409946&r2=1409947&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
Thu Nov 15 19:40:07 2012
@@ -203,7 +203,7 @@ public class OpenBaseAdapter extends Jdb
             }
 
             String type = types[0];
-            buf.append(context.quoteString(at.getName())).append(' ').append(type);
+            buf.append(context.quotedIdentifier(at.getName())).append(' ').append(type);
 
             // append size and precision (if applicable)
             if (TypesMapping.supportsLength(at.getType())) {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/openbase/OpenBasePkGenerator.java
Thu Nov 15 19:40:07 2012
@@ -232,7 +232,7 @@ public class OpenBasePkGenerator extends
         }
         QuotingStrategy context = getAdapter().getQuotingStrategy(status);
 
-        buffer.append(context.quoteString(entity.getName()));
+        buffer.append(context.quotedIdentifier(entity.getName()));
 
         buffer.append(" (");
 
@@ -240,12 +240,12 @@ public class OpenBasePkGenerator extends
 
         // at this point we know that there is at least on PK column
         DbAttribute firstColumn = it.next();
-        buffer.append(context.quoteString(firstColumn.getName()));
+        buffer.append(context.quotedIdentifier(firstColumn.getName()));
 
         while (it.hasNext()) {
             DbAttribute column = it.next();
             buffer.append(", ");
-            buffer.append(context.quoteString(column.getName()));
+            buffer.append(context.quotedIdentifier(column.getName()));
         }
 
         buffer.append(")");
@@ -278,19 +278,19 @@ public class OpenBasePkGenerator extends
         // create a regular one in this case
         buffer.append(pk.size() == 1 ? "CREATE UNIQUE INDEX " : "CREATE INDEX ");
 
-        buffer.append(context.quoteString(entity.getName()));
+        buffer.append(context.quotedIdentifier(entity.getName()));
         buffer.append(" (");
 
         Iterator<DbAttribute> it = pk.iterator();
 
         // at this point we know that there is at least on PK column
         DbAttribute firstColumn = it.next();
-        buffer.append(context.quoteString(firstColumn.getName()));
+        buffer.append(context.quotedIdentifier(firstColumn.getName()));
 
         while (it.hasNext()) {
             DbAttribute column = it.next();
             buffer.append(", ");
-            buffer.append(context.quoteString(column.getName()));
+            buffer.append(context.quotedIdentifier(column.getName()));
         }
         buffer.append(")");
         return buffer.toString();

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OracleMergerFactory.java
Thu Nov 15 19:40:07 2012
@@ -44,7 +44,7 @@ public class OracleMergerFactory extends
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ADD ");
-                sqlBuffer.append(context.quoteString(column.getName()));
+                sqlBuffer.append(context.quotedIdentifier(column.getName()));
                 sqlBuffer.append(" ");
             }
         };
@@ -63,7 +63,7 @@ public class OracleMergerFactory extends
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(context.quoteString(columnNew.getName()));
+                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/oracle/OraclePkGenerator.java
Thu Nov 15 19:40:07 2012
@@ -38,14 +38,15 @@ import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbKeyGenerator;
 
 /**
- * Sequence-based primary key generator implementation for Oracle. Uses Oracle sequences
- * to generate primary key values. This approach is at least 50% faster when tested with
- * Oracle compared to the lookup table approach.
+ * Sequence-based primary key generator implementation for Oracle. Uses Oracle
+ * sequences to generate primary key values. This approach is at least 50%
+ * faster when tested with Oracle compared to the lookup table approach.
  * <p>
- * When using Cayenne key caching mechanism, make sure that sequences in the database have
- * "INCREMENT BY" greater or equal to OraclePkGenerator "pkCacheSize" property value. If
- * this is not the case, you will need to adjust PkGenerator value accordingly. For
- * example when sequence is incremented by 1 each time, use the following code:
+ * When using Cayenne key caching mechanism, make sure that sequences in the
+ * database have "INCREMENT BY" greater or equal to OraclePkGenerator
+ * "pkCacheSize" property value. If this is not the case, you will need to
+ * adjust PkGenerator value accordingly. For example when sequence is
+ * incremented by 1 each time, use the following code:
  * </p>
  * 
  * <pre>
@@ -102,8 +103,7 @@ public class OraclePkGenerator extends J
                 tempEnt.setDataMap(dm);
                 tempEnt.setName(ent.getName());
                 name = stripSchemaName(sequenceName(tempEnt));
-            }
-            else {
+            } else {
                 name = stripSchemaName(sequenceName(ent));
             }
             if (sequences.contains(name)) {
@@ -126,18 +126,14 @@ public class OraclePkGenerator extends J
 
     protected String createSequenceString(DbEntity ent) {
         StringBuilder buf = new StringBuilder();
-        buf
-                .append("CREATE SEQUENCE ")
-                .append(sequenceName(ent))
-                .append(" START WITH 200")
-                .append(" INCREMENT BY ")
+        buf.append("CREATE SEQUENCE ").append(sequenceName(ent)).append(" START WITH 200").append("
INCREMENT BY ")
                 .append(pkCacheSize(ent));
         return buf.toString();
     }
 
     /**
-     * Returns a SQL string needed to drop any database objects associated with automatic
-     * primary key generation process for a specific DbEntity.
+     * Returns a SQL string needed to drop any database objects associated with
+     * automatic primary key generation process for a specific DbEntity.
      */
     protected String dropSequenceString(DbEntity ent) {
 
@@ -161,8 +157,7 @@ public class OraclePkGenerator extends J
 
         DbKeyGenerator pkGenerator = entity.getPrimaryKeyGenerator();
         String pkGeneratingSequenceName;
-        if (pkGenerator != null
-                && DbKeyGenerator.ORACLE_TYPE.equals(pkGenerator.getGeneratorType())
+        if (pkGenerator != null && DbKeyGenerator.ORACLE_TYPE.equals(pkGenerator.getGeneratorType())
                 && pkGenerator.getGeneratorName() != null)
             pkGeneratingSequenceName = pkGenerator.getGeneratorName();
         else
@@ -178,20 +173,16 @@ public class OraclePkGenerator extends J
                 try {
                     // Object pk = null;
                     if (!rs.next()) {
-                        throw new CayenneRuntimeException(
-                                "Error generating pk for DbEntity " + entity.getName());
+                        throw new CayenneRuntimeException("Error generating pk for DbEntity
" + entity.getName());
                     }
                     return rs.getLong(1);
-                }
-                finally {
+                } finally {
                     rs.close();
                 }
-            }
-            finally {
+            } finally {
                 st.close();
             }
-        }
-        finally {
+        } finally {
             con.close();
         }
 
@@ -200,15 +191,12 @@ public class OraclePkGenerator extends J
     protected int pkCacheSize(DbEntity entity) {
         // use custom generator if possible
         DbKeyGenerator keyGenerator = entity.getPrimaryKeyGenerator();
-        if (keyGenerator != null
-                && DbKeyGenerator.ORACLE_TYPE.equals(keyGenerator.getGeneratorType())
+        if (keyGenerator != null && DbKeyGenerator.ORACLE_TYPE.equals(keyGenerator.getGeneratorType())
                 && keyGenerator.getGeneratorName() != null) {
 
             Integer size = keyGenerator.getKeyCacheSize();
-            return (size != null && size.intValue() >= 1) ? size.intValue() :
super
-                    .getPkCacheSize();
-        }
-        else {
+            return (size != null && size.intValue() >= 1) ? size.intValue() :
super.getPkCacheSize();
+        } else {
             return super.getPkCacheSize();
         }
     }
@@ -218,34 +206,22 @@ public class OraclePkGenerator extends J
         boolean status;
         if (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers())
{
             status = true;
-        }
-        else {
+        } else {
             status = false;
         }
         QuotingStrategy context = getAdapter().getQuotingStrategy(status);
 
         // use custom generator if possible
         DbKeyGenerator keyGenerator = entity.getPrimaryKeyGenerator();
-        if (keyGenerator != null
-                && DbKeyGenerator.ORACLE_TYPE.equals(keyGenerator.getGeneratorType())
+        if (keyGenerator != null && DbKeyGenerator.ORACLE_TYPE.equals(keyGenerator.getGeneratorType())
                 && keyGenerator.getGeneratorName() != null) {
 
             return keyGenerator.getGeneratorName().toLowerCase();
-        }
-        else {
+        } else {
             String entName = entity.getName();
             String seqName = _SEQUENCE_PREFIX + entName.toLowerCase();
 
-            if (entity.getSchema() != null && entity.getSchema().length() > 0)
{
-
-                seqName = context.quoteString(entity.getSchema())
-                        + "."
-                        + context.quoteString(seqName);
-            }
-            else {
-                seqName = context.quoteString(seqName);
-            }
-            return seqName;
+            return context.quotedIdentifier(entity.getSchema(), seqName);
         }
     }
 
@@ -255,7 +231,8 @@ public class OraclePkGenerator extends J
     }
 
     /**
-     * Fetches a list of existing sequences that might match Cayenne generated ones.
+     * Fetches a list of existing sequences that might match Cayenne generated
+     * ones.
      */
     protected List getExistingSequences(DataNode node) throws SQLException {
 
@@ -274,16 +251,13 @@ public class OraclePkGenerator extends J
                         sequenceList.add(rs.getString(1));
                     }
                     return sequenceList;
-                }
-                finally {
+                } finally {
                     rs.close();
                 }
-            }
-            finally {
+            } finally {
                 sel.close();
             }
-        }
-        finally {
+        } finally {
             con.close();
         }
     }

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=1409947&r1=1409946&r2=1409947&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
Thu Nov 15 19:40:07 2012
@@ -178,7 +178,7 @@ public class PostgresAdapter extends Jdb
             }
 
             String type = types[0];
-            buf.append(context.quoteString(at.getName())).append(' ').append(type);
+            buf.append(context.quotedIdentifier(at.getName())).append(' ').append(type);
 
             // append size and precision (if applicable)
             if (typeSupportsLength(at.getType())) {
@@ -233,7 +233,7 @@ public class PostgresAdapter extends Jdb
                     buf.append(", ");
 
                 DbAttribute at = pkit.next();
-                buf.append(context.quoteString(at.getName()));
+                buf.append(context.quotedIdentifier(at.getName()));
             }
             buf.append(')');
         }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresMergerFactory.java
Thu Nov 15 19:40:07 2012
@@ -41,7 +41,7 @@ public class PostgresMergerFactory exten
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER ");
-                sqlBuffer.append(context.quoteString(columnNew.getName()));
+                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
                 sqlBuffer.append(" TYPE ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/postgres/PostgresPkGenerator.java
Thu Nov 15 19:40:07 2012
@@ -131,7 +131,7 @@ public class PostgresPkGenerator extends
                 try {
                     List<String> sequenceList = new ArrayList<String>();
                     while (rs.next()) {
-                        sequenceList.add(context.quoteString(rs.getString(1)));
+                        sequenceList.add(context.quotedIdentifier(rs.getString(1)));
                     }
                     return sequenceList;
                 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sqlserver/SQLServerMergerFactory.java
Thu Nov 15 19:40:07 2012
@@ -48,7 +48,7 @@ public class SQLServerMergerFactory exte
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ALTER COLUMN ");
-                sqlBuffer.append(context.quoteString(columnNew.getName()));
+                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
         };
@@ -64,7 +64,7 @@ public class SQLServerMergerFactory exte
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" ADD ");
-                sqlBuffer.append(context.quoteString(column.getName()));
+                sqlBuffer.append(context.quotedIdentifier(column.getName()));
                 sqlBuffer.append(" ");
             }
         };

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/sybase/SybaseMergerFactory.java
Thu Nov 15 19:40:07 2012
@@ -83,7 +83,7 @@ public class SybaseMergerFactory extends
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
                 sqlBuffer.append(" DROP ");
-                sqlBuffer.append(context.quoteString(getColumn().getName()));
+                sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
 
                 return Collections.singletonList(sqlBuffer.toString());
             }
@@ -147,7 +147,7 @@ public class SybaseMergerFactory extends
                 sqlBuffer.append("ALTER TABLE ");
                 sqlBuffer.append(context.quoteFullyQualifiedName(entity));
                 sqlBuffer.append(" MODIFY ");
-                sqlBuffer.append(context.quoteString(columnNew.getName()));
+                sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
                 sqlBuffer.append(" ");
             }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToDb.java
Thu Nov 15 19:40:07 2012
@@ -42,7 +42,7 @@ public class AddColumnToDb extends Abstr
         sqlBuffer.append("ALTER TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ADD COLUMN ");
-        sqlBuffer.append(context.quoteString(getColumn().getName()));
+        sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
         sqlBuffer.append(" ");
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToDb.java
Thu Nov 15 19:40:07 2012
@@ -41,7 +41,7 @@ public class DropColumnToDb extends Abst
         sqlBuffer.append("ALTER TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" DROP COLUMN ");
-        sqlBuffer.append(context.quoteString(getColumn().getName()));
+        sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
 
         return Collections.singletonList(sqlBuffer.toString());
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToDb.java
Thu Nov 15 19:40:07 2012
@@ -45,7 +45,7 @@ public class SetAllowNullToDb extends Ab
         sqlBuffer.append("ALTER TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER COLUMN ");
-        sqlBuffer.append(context.quoteString(getColumn().getName()));
+        sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
         sqlBuffer.append(" DROP NOT NULL");
 
         return Collections.singletonList(sqlBuffer.toString());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToDb.java
Thu Nov 15 19:40:07 2012
@@ -50,7 +50,7 @@ public class SetColumnTypeToDb extends A
         sqlBuffer.append("ALTER TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER ");
-        sqlBuffer.append(context.quoteString(columnNew.getName()));
+        sqlBuffer.append(context.quotedIdentifier(columnNew.getName()));
         sqlBuffer.append(" TYPE ");
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToDb.java
Thu Nov 15 19:40:07 2012
@@ -44,7 +44,7 @@ public class SetNotNullToDb extends Abst
         sqlBuffer.append("ALTER TABLE ");
         sqlBuffer.append(context.quoteFullyQualifiedName(getEntity()));
         sqlBuffer.append(" ALTER COLUMN ");
-        sqlBuffer.append(context.quoteString(getColumn().getName()));
+        sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
         sqlBuffer.append(" SET NOT NULL");
 
         return Collections.singletonList(sqlBuffer.toString());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetPrimaryKeyToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetPrimaryKeyToDb.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetPrimaryKeyToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetPrimaryKeyToDb.java
Thu Nov 15 19:40:07 2012
@@ -24,6 +24,7 @@ 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.map.DbEntity;
 
@@ -56,20 +57,19 @@ public class SetPrimaryKeyToDb extends A
         if (detectedPrimaryKeyName == null) {
             return;
         }
-        sqls.add("ALTER TABLE "
-                + getQuotingStrategy(adapter)
-                        .quoteFullyQualifiedName(getEntity())
-                + " DROP CONSTRAINT "
-                + detectedPrimaryKeyName);
+        sqls.add("ALTER TABLE " + getQuotingStrategy(adapter).quoteFullyQualifiedName(getEntity())
+                + " DROP CONSTRAINT " + detectedPrimaryKeyName);
     }
 
     protected void appendAddNewPrimaryKeySQL(DbAdapter adapter, List<String> sqls)
{
+        QuotingStrategy quotingStrategy = getQuotingStrategy(adapter);
+
         StringBuilder sql = new StringBuilder();
         sql.append("ALTER TABLE ");
-        sql.append(getQuotingStrategy(adapter).quoteFullyQualifiedName(getEntity()));
+        sql.append(quotingStrategy.quoteFullyQualifiedName(getEntity()));
         sql.append(" ADD PRIMARY KEY (");
         for (Iterator<DbAttribute> it = primaryKeyNew.iterator(); it.hasNext();) {
-            sql.append(getQuotingStrategy(adapter).quoteString(it.next().getName()));
+            sql.append(quotingStrategy.quotedIdentifier(it.next().getName()));
             if (it.hasNext()) {
                 sql.append(", ");
             }
@@ -79,10 +79,7 @@ public class SetPrimaryKeyToDb extends A
     }
 
     public MergerToken createReverse(MergerFactory factory) {
-        return factory.createSetPrimaryKeyToModel(
-                getEntity(),
-                primaryKeyNew,
-                primaryKeyOriginal,
+        return factory.createSetPrimaryKeyToModel(getEntity(), primaryKeyNew, primaryKeyOriginal,
                 detectedPrimaryKeyName);
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/UnitDbAdapter.java
Thu Nov 15 19:40:07 2012
@@ -336,7 +336,7 @@ public class UnitDbAdapter {
                             constraintMap.put(fkTable, constraints);
                         }
 
-                        constraints.add(strategy.quoteString(fk));
+                        constraints.add(strategy.quotedIdentifier(fk));
                     }
                 }
             }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.java
Thu Nov 15 19:40:07 2012
@@ -37,7 +37,7 @@ public class FlavoredDBHelper extends DB
 
     @Override
     protected String quote(String sqlIdentifier) {
-        return quotingStrategy.quoteString(sqlIdentifier);
+        return quotingStrategy.quotedIdentifier(sqlIdentifier);
     }
 
 }



Mime
View raw message