You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2012/11/15 20:40:15 UTC
svn commit: r1409947 [1/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...
Author: aadamchik
Date: Thu Nov 15 19:40:07 2012
New Revision: 1409947
URL: http://svn.apache.org/viewvc?rev=1409947&view=rev
Log:
CAY-1772 Real support for DbEntity catalogs
* new QuotingStrategy API to quote arbitrary set of dentifier parts
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/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/UpdateBatchQueryBuilder.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/NoQuotingStrategy.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/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/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/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/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/unit/UnitDbAdapter.java
cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/di/server/FlavoredDBHelper.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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -188,7 +188,7 @@ final class FlattenedArcKey {
DbAttribute attribute = pkList.get(i);
sql.append("#result('");
- sql.append(quoter.quoteString(attribute.getName()));
+ sql.append(quoter.quotedIdentifier(attribute.getName()));
if (quotesNeeded) {
// since the name of the column can potentially be quoted and
@@ -208,7 +208,7 @@ final class FlattenedArcKey {
.append(" WHERE ");
int i = snapshot.size();
for (Object key : snapshot.keySet()) {
- sql.append(quoter.quoteString(String.valueOf(key)))
+ sql.append(quoter.quotedIdentifier(String.valueOf(key)))
.append(" #bindEqual($").append(key).append(")");
if (--i > 0) {
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -87,8 +87,7 @@ public class ColumnDescriptor implements
/**
* @since 1.2
*/
- public ColumnDescriptor(ObjAttribute objAttribute, DbAttribute dbAttribute,
- String columnAlias) {
+ public ColumnDescriptor(ObjAttribute objAttribute, DbAttribute dbAttribute, String columnAlias) {
this(dbAttribute, columnAlias);
this.dataRowKey = objAttribute.getDbAttributePath();
this.javaClass = objAttribute.getType();
@@ -112,8 +111,7 @@ public class ColumnDescriptor implements
*
* @since 3.1
*/
- public ColumnDescriptor(String columnName, ResultSetMetaData metaData, int position)
- throws SQLException {
+ public ColumnDescriptor(String columnName, ResultSetMetaData metaData, int position) throws SQLException {
this(columnName, metaData.getColumnType(position));
}
@@ -126,8 +124,7 @@ public class ColumnDescriptor implements
this(getColumnNameFromMeta(metaData, position), metaData, position);
}
- private static String getColumnNameFromMeta(ResultSetMetaData metaData, int position)
- throws SQLException {
+ private static String getColumnNameFromMeta(ResultSetMetaData metaData, int position) throws SQLException {
String name = metaData.getColumnLabel(position);
if (name == null || name.length() == 0) {
name = metaData.getColumnName(position);
@@ -140,8 +137,9 @@ public class ColumnDescriptor implements
}
/**
- * Returns true if another object is a ColumnDescriptor with the same name, name
- * prefix, table and procedure names. Other fields are ignored in the equality test.
+ * Returns true if another object is a ColumnDescriptor with the same name,
+ * name prefix, table and procedure names. Other fields are ignored in the
+ * equality test.
*
* @since 1.2
*/
@@ -152,13 +150,9 @@ public class ColumnDescriptor implements
}
ColumnDescriptor rhs = (ColumnDescriptor) o;
- return new EqualsBuilder()
- .append(name, rhs.name)
- .append(namePrefix, rhs.namePrefix)
- .append(procedureName, rhs.procedureName)
- .append(dataRowKey, rhs.dataRowKey)
- .append(tableName, rhs.tableName)
- .isEquals();
+ return new EqualsBuilder().append(name, rhs.name).append(namePrefix, rhs.namePrefix)
+ .append(procedureName, rhs.procedureName).append(dataRowKey, rhs.dataRowKey)
+ .append(tableName, rhs.tableName).isEquals();
}
/**
@@ -166,13 +160,8 @@ public class ColumnDescriptor implements
*/
@Override
public int hashCode() {
- return new HashCodeBuilder(23, 43)
- .append(name)
- .append(namePrefix)
- .append(procedureName)
- .append(tableName)
- .append(dataRowKey)
- .toHashCode();
+ return new HashCodeBuilder(23, 43).append(name).append(namePrefix).append(procedureName).append(tableName)
+ .append(dataRowKey).toHashCode();
}
/**
@@ -201,10 +190,7 @@ public class ColumnDescriptor implements
}
public String getQualifiedColumnNameWithQuoteSqlIdentifiers(QuotingStrategy strategy) {
- String nameWithQuoteSqlIdentifiers = strategy.quoteString(name);
- return (namePrefix != null) ? strategy.quoteString(namePrefix)
- + '.'
- + nameWithQuoteSqlIdentifiers : nameWithQuoteSqlIdentifiers;
+ return strategy.quotedIdentifier(namePrefix, name);
}
public int getJdbcType() {
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -55,7 +55,7 @@ public class SoftDeleteBatchQueryBuilder
StringBuffer query = new StringBuffer("UPDATE ");
query.append(strategy.quoteFullyQualifiedName(batch.getDbEntity()));
- query.append(" SET ").append(strategy.quoteString(deletedFieldName)).append(
+ query.append(" SET ").append(strategy.quotedIdentifier(deletedFieldName)).append(
" = ?");
applyQualifier(query, batch);
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -72,7 +72,7 @@ public abstract class BatchQueryBuilder
}
QuotingStrategy strategy = getAdapter().getQuotingStrategy(status);
- buf.append(strategy.quoteString(dbAttribute.getName()));
+ buf.append(strategy.quotedIdentifier(dbAttribute.getName()));
if (trim) {
buf.append(')');
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -113,7 +113,7 @@ public class InsertBatchQueryBuilder ext
if (columnCount > 0) {
query.append(", ");
}
- query.append(strategy.quoteString(attribute.getName()));
+ query.append(strategy.quotedIdentifier(attribute.getName()));
columnCount++;
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/trans/JoinStack.java?rev=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -87,7 +87,7 @@ public class JoinStack {
out.append(quotingStrategy.quoteFullyQualifiedName(rootEntity));
out.append(' ');
- out.append(quotingStrategy.quoteString(rootNode.getTargetTableAlias()));
+ out.append(quotingStrategy.quotedIdentifier(rootNode.getTargetTableAlias()));
}
/**
@@ -124,7 +124,7 @@ public class JoinStack {
out.append(quotingStrategy.quoteFullyQualifiedName(targetEntity));
out.append(' ');
- out.append(quotingStrategy.quoteString(targetAlias));
+ out.append(quotingStrategy.quotedIdentifier(targetAlias));
out.append(" ON (");
List<DbJoin> joins = relationship.getJoins();
@@ -135,13 +135,9 @@ public class JoinStack {
out.append(" AND ");
}
- out.append(quotingStrategy.quoteString(srcAlias));
- out.append('.');
- out.append(quotingStrategy.quoteString(join.getSourceName()));
+ out.append(quotingStrategy.quotedIdentifier(srcAlias, join.getSourceName()));
out.append(" = ");
- out.append(quotingStrategy.quoteString(targetAlias));
- out.append('.');
- out.append(quotingStrategy.quoteString(join.getTargetName()));
+ out.append(quotingStrategy.quotedIdentifier(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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -68,7 +68,7 @@ public abstract class LOBBatchQueryBuild
Iterator it = selectedLOBAttributes.iterator();
while (it.hasNext()) {
- buf.append(strategy.quoteString(((DbAttribute) it.next()).getName()));
+ buf.append(strategy.quotedIdentifier(((DbAttribute) it.next()).getName()));
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -70,7 +70,7 @@ public class LOBInsertBatchQueryBuilder
for (Iterator<DbAttribute> i = dbAttributes.iterator(); i.hasNext();) {
DbAttribute attribute = i.next();
- query.append(strategy.quoteString(attribute.getName()));
+ query.append(strategy.quotedIdentifier(attribute.getName()));
if (i.hasNext()) {
query.append(", ");
}
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -89,7 +89,7 @@ public class LOBUpdateBatchQueryBuilder
}
DbAttribute attribute = updatedDbAttributes.get(i);
- query.append(strategy.quoteString(attribute.getName()));
+ query.append(strategy.quotedIdentifier(attribute.getName()));
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -44,7 +44,8 @@ import org.apache.cayenne.map.PathCompon
import org.apache.cayenne.util.CayenneMapEntry;
/**
- * Translates parts of the query to SQL. Always works in the context of parent Translator.
+ * Translates parts of the query to SQL. Always works in the context of parent
+ * Translator.
*/
public abstract class QueryAssemblerHelper {
@@ -53,20 +54,16 @@ public abstract class QueryAssemblerHelp
protected QuotingStrategy strategy;
/**
- * Creates QueryAssemblerHelper initializing with parent {@link QueryAssembler} and
- * output buffer object.
+ * Creates QueryAssemblerHelper initializing with parent
+ * {@link QueryAssembler} and output buffer object.
*/
public QueryAssemblerHelper(QueryAssembler queryAssembler) {
this.queryAssembler = queryAssembler;
boolean status;
if (queryAssembler.getQueryMetadata().getDataMap() != null
- && queryAssembler
- .getQueryMetadata()
- .getDataMap()
- .isQuotingSQLIdentifiers()) {
+ && queryAssembler.getQueryMetadata().getDataMap().isQuotingSQLIdentifiers()) {
status = true;
- }
- else {
+ } else {
status = false;
}
strategy = queryAssembler.getAdapter().getQuotingStrategy(status);
@@ -109,23 +106,22 @@ public abstract class QueryAssemblerHelp
protected abstract void doAppendPart() throws IOException;
/**
- * Outputs the standard JDBC (database agnostic) expression for supplying the escape
- * character to the database server when supplying a LIKE clause. This has been
- * factored-out because some database adaptors handle LIKE differently and they need
- * access to this common method in order not to repeat this code. </p>
+ * Outputs the standard JDBC (database agnostic) expression for supplying
+ * the escape character to the database server when supplying a LIKE clause.
+ * This has been factored-out because some database adaptors handle LIKE
+ * differently and they need access to this common method in order not to
+ * repeat this code. </p>
* <p>
- * If there is no escape character defined then this method will not output anything.
- * An escape character of 0 will mean no escape character.
+ * If there is no escape character defined then this method will not output
+ * anything. An escape character of 0 will mean no escape character.
*
* @since 3.1
*/
- protected void appendLikeEscapeCharacter(PatternMatchNode patternMatchNode)
- throws IOException {
+ protected void appendLikeEscapeCharacter(PatternMatchNode patternMatchNode) throws IOException {
char escapeChar = patternMatchNode.getEscapeChar();
if ('?' == escapeChar) {
- throw new CayenneRuntimeException(
- "the escape character of '?' is illegal for LIKE clauses.");
+ throw new CayenneRuntimeException("the escape character of '?' is illegal for LIKE clauses.");
}
if (0 != escapeChar) {
@@ -143,33 +139,25 @@ public abstract class QueryAssemblerHelp
queryAssembler.resetJoinStack();
String joinSplitAlias = null;
- for (PathComponent<ObjAttribute, ObjRelationship> component : getObjEntity()
- .resolvePath(pathExp, queryAssembler.getPathAliases())) {
+ for (PathComponent<ObjAttribute, ObjRelationship> component : getObjEntity().resolvePath(pathExp,
+ queryAssembler.getPathAliases())) {
if (component.isAlias()) {
joinSplitAlias = component.getName();
- for (PathComponent<ObjAttribute, ObjRelationship> aliasPart : component
- .getAliasedPath()) {
+ for (PathComponent<ObjAttribute, ObjRelationship> aliasPart : component.getAliasedPath()) {
ObjRelationship relationship = aliasPart.getRelationship();
if (relationship == null) {
- throw new IllegalStateException(
- "Non-relationship aliased path part: "
- + aliasPart.getName());
+ throw new IllegalStateException("Non-relationship aliased path part: " + aliasPart.getName());
}
if (aliasPart.isLast() && component.isLast()) {
- processRelTermination(
- relationship,
- aliasPart.getJoinType(),
- joinSplitAlias);
- }
- else {
+ processRelTermination(relationship, aliasPart.getJoinType(), joinSplitAlias);
+ } else {
// find and add joins ....
for (DbRelationship dbRel : relationship.getDbRelationships()) {
- queryAssembler.dbRelationshipAdded(dbRel, aliasPart
- .getJoinType(), joinSplitAlias);
+ queryAssembler.dbRelationshipAdded(dbRel, aliasPart.getJoinType(), joinSplitAlias);
}
}
}
@@ -185,37 +173,23 @@ public abstract class QueryAssemblerHelp
// if this is a last relationship in the path,
// it needs special handling
if (component.isLast()) {
- processRelTermination(
- relationship,
- component.getJoinType(),
- joinSplitAlias);
- }
- else {
+ processRelTermination(relationship, component.getJoinType(), joinSplitAlias);
+ } else {
// find and add joins ....
for (DbRelationship dbRel : relationship.getDbRelationships()) {
- queryAssembler.dbRelationshipAdded(
- dbRel,
- component.getJoinType(),
- joinSplitAlias);
+ queryAssembler.dbRelationshipAdded(dbRel, component.getJoinType(), joinSplitAlias);
}
}
- }
- else {
+ } else {
Iterator<CayenneMapEntry> dbPathIterator = attribute.getDbPathIterator();
while (dbPathIterator.hasNext()) {
Object pathPart = dbPathIterator.next();
if (pathPart == null) {
- throw new CayenneRuntimeException(
- "ObjAttribute has no component: " + attribute.getName());
- }
- else if (pathPart instanceof DbRelationship) {
- queryAssembler.dbRelationshipAdded(
- (DbRelationship) pathPart,
- JoinType.INNER,
- joinSplitAlias);
- }
- else if (pathPart instanceof DbAttribute) {
+ throw new CayenneRuntimeException("ObjAttribute has no component: " + attribute.getName());
+ } else if (pathPart instanceof DbRelationship) {
+ queryAssembler.dbRelationshipAdded((DbRelationship) pathPart, JoinType.INNER, joinSplitAlias);
+ } else if (pathPart instanceof DbAttribute) {
processColumnWithQuoteSqlIdentifiers((DbAttribute) pathPart, pathExp);
}
}
@@ -229,31 +203,23 @@ public abstract class QueryAssemblerHelp
queryAssembler.resetJoinStack();
String joinSplitAlias = null;
- for (PathComponent<DbAttribute, DbRelationship> component : getDbEntity()
- .resolvePath(pathExp, queryAssembler.getPathAliases())) {
+ for (PathComponent<DbAttribute, DbRelationship> component : getDbEntity().resolvePath(pathExp,
+ queryAssembler.getPathAliases())) {
if (component.isAlias()) {
joinSplitAlias = component.getName();
- for (PathComponent<DbAttribute, DbRelationship> aliasPart : component
- .getAliasedPath()) {
+ for (PathComponent<DbAttribute, DbRelationship> aliasPart : component.getAliasedPath()) {
DbRelationship relationship = aliasPart.getRelationship();
if (relationship == null) {
- throw new IllegalStateException(
- "Non-relationship aliased path part: "
- + aliasPart.getName());
+ throw new IllegalStateException("Non-relationship aliased path part: " + aliasPart.getName());
}
if (aliasPart.isLast() && component.isLast()) {
- processRelTermination(
- relationship,
- aliasPart.getJoinType(),
- joinSplitAlias);
- }
- else {
- queryAssembler.dbRelationshipAdded(relationship, component
- .getJoinType(), joinSplitAlias);
+ processRelTermination(relationship, aliasPart.getJoinType(), joinSplitAlias);
+ } else {
+ queryAssembler.dbRelationshipAdded(relationship, component.getJoinType(), joinSplitAlias);
}
}
@@ -267,18 +233,12 @@ public abstract class QueryAssemblerHelp
// if this is a last relationship in the path,
// it needs special handling
if (component.isLast()) {
- processRelTermination(
- relationship,
- component.getJoinType(),
- joinSplitAlias);
- }
- else {
+ processRelTermination(relationship, component.getJoinType(), joinSplitAlias);
+ } else {
// find and add joins ....
- queryAssembler.dbRelationshipAdded(relationship, component
- .getJoinType(), joinSplitAlias);
+ queryAssembler.dbRelationshipAdded(relationship, component.getJoinType(), joinSplitAlias);
}
- }
- else {
+ } else {
processColumnWithQuoteSqlIdentifiers(component.getAttribute(), pathExp);
}
}
@@ -288,90 +248,69 @@ public abstract class QueryAssemblerHelp
processColumnWithQuoteSqlIdentifiers(dbAttr, null);
}
- protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp)
- throws IOException {
-
- String alias = (queryAssembler.supportsTableAliases()) ? queryAssembler
- .getCurrentAlias() : null;
-
- if (alias != null) {
+ protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) throws IOException {
- out.append(strategy.quoteString(alias));
- out.append(".");
- }
- out.append(strategy.quoteString(dbAttr.getName()));
+ String alias = (queryAssembler.supportsTableAliases()) ? queryAssembler.getCurrentAlias() : null;
+ out.append(strategy.quotedIdentifier(alias, dbAttr.getName()));
}
/**
- * Appends SQL code to the query buffer to handle <code>val</code> as a parameter to
- * the PreparedStatement being built. Adds <code>val</code> into QueryAssembler
- * parameter list.
+ * Appends SQL code to the query buffer to handle <code>val</code> as a
+ * parameter to the PreparedStatement being built. Adds <code>val</code>
+ * into QueryAssembler parameter list.
* <p>
* If <code>val</code> is null, "NULL" is appended to the query.
* </p>
* <p>
- * If <code>val</code> is a DataObject, its primary key value is used as a parameter.
- * <i>Only objects with a single column primary key can be used.</i>
+ * If <code>val</code> is a DataObject, its primary key value is used as a
+ * parameter. <i>Only objects with a single column primary key can be
+ * used.</i>
*
- * @param val object that should be appended as a literal to the query. Must be of one
- * of "standard JDBC" types, null or a DataObject.
- * @param attr DbAttribute that has information on what type of parameter is being
- * appended.
+ * @param val
+ * object that should be appended as a literal to the query. Must
+ * be of one of "standard JDBC" types, null or a DataObject.
+ * @param attr
+ * DbAttribute that has information on what type of parameter is
+ * being appended.
*/
- protected void appendLiteral(Object val, DbAttribute attr, Expression parentExpression)
- throws IOException {
+ protected void appendLiteral(Object val, DbAttribute attr, Expression parentExpression) throws IOException {
if (val == null) {
out.append("NULL");
- }
- else if (val instanceof Persistent) {
+ } else if (val instanceof Persistent) {
ObjectId id = ((Persistent) val).getObjectId();
// check if this id is acceptable to be a parameter
if (id == null) {
- throw new CayenneRuntimeException(
- "Can't use TRANSIENT object as a query parameter.");
+ throw new CayenneRuntimeException("Can't use TRANSIENT object as a query parameter.");
}
if (id.isTemporary()) {
- throw new CayenneRuntimeException(
- "Can't use NEW object as a query parameter.");
+ throw new CayenneRuntimeException("Can't use NEW object as a query parameter.");
}
Map<String, Object> snap = id.getIdSnapshot();
if (snap.size() != 1) {
StringBuilder msg = new StringBuilder();
- msg
- .append("Object must have a single primary key column ")
- .append("to serve as a query parameter. ")
- .append("This object has ")
- .append(snap.size())
- .append(": ")
- .append(snap);
+ msg.append("Object must have a single primary key column ").append("to serve as a query parameter. ")
+ .append("This object has ").append(snap.size()).append(": ").append(snap);
throw new CayenneRuntimeException(msg.toString());
}
// checks have been passed, use id value
- appendLiteralDirect(
- snap.get(snap.keySet().iterator().next()),
- attr,
- parentExpression);
- }
- else {
+ appendLiteralDirect(snap.get(snap.keySet().iterator().next()), attr, parentExpression);
+ } else {
appendLiteralDirect(val, attr, parentExpression);
}
}
/**
- * Appends SQL code to the query buffer to handle <code>val</code> as a parameter to
- * the PreparedStatement being built. Adds <code>val</code> into QueryAssembler
- * parameter list.
- */
- protected void appendLiteralDirect(
- Object val,
- DbAttribute attr,
- Expression parentExpression) throws IOException {
+ * Appends SQL code to the query buffer to handle <code>val</code> as a
+ * parameter to the PreparedStatement being built. Adds <code>val</code>
+ * into QueryAssembler parameter list.
+ */
+ protected void appendLiteralDirect(Object val, DbAttribute attr, Expression parentExpression) throws IOException {
out.append('?');
// we are hoping that when processing parameter list,
@@ -381,12 +320,14 @@ public abstract class QueryAssemblerHelp
}
/**
- * Returns database type of expression parameters or null if it can not be determined.
+ * Returns database type of expression parameters or null if it can not be
+ * determined.
*/
protected DbAttribute paramsDbType(Expression e) {
int len = e.getOperandCount();
- // for unary expressions, find parent binary - this is a hack mainly to support
+ // for unary expressions, find parent binary - this is a hack mainly to
+ // support
// ASTList
if (len < 2) {
@@ -415,10 +356,8 @@ public abstract class QueryAssemblerHelp
if (op instanceof Expression) {
Expression expression = (Expression) op;
if (expression.getType() == Expression.OBJ_PATH) {
- PathComponent<ObjAttribute, ObjRelationship> last = getObjEntity()
- .lastPathComponent(
- expression,
- queryAssembler.getPathAliases());
+ PathComponent<ObjAttribute, ObjRelationship> last = getObjEntity().lastPathComponent(expression,
+ queryAssembler.getPathAliases());
// TODO: handle EmbeddableAttribute
// if (last instanceof EmbeddableAttribute)
@@ -427,27 +366,20 @@ public abstract class QueryAssemblerHelp
if (last.getAttribute() != null) {
attribute = last.getAttribute().getDbAttribute();
break;
- }
- else if (last.getRelationship() != null) {
- List<DbRelationship> dbPath = last
- .getRelationship()
- .getDbRelationships();
+ } else if (last.getRelationship() != null) {
+ List<DbRelationship> dbPath = last.getRelationship().getDbRelationships();
if (dbPath.size() > 0) {
relationship = dbPath.get(dbPath.size() - 1);
break;
}
}
- }
- else if (expression.getType() == Expression.DB_PATH) {
- PathComponent<DbAttribute, DbRelationship> last = getDbEntity()
- .lastPathComponent(
- expression,
- queryAssembler.getPathAliases());
+ } else if (expression.getType() == Expression.DB_PATH) {
+ PathComponent<DbAttribute, DbRelationship> last = getDbEntity().lastPathComponent(expression,
+ queryAssembler.getPathAliases());
if (last.getAttribute() != null) {
attribute = last.getAttribute();
break;
- }
- else if (last.getRelationship() != null) {
+ } else if (last.getRelationship() != null) {
relationship = last.getRelationship();
break;
}
@@ -471,17 +403,15 @@ public abstract class QueryAssemblerHelp
}
/**
- * Processes case when an OBJ_PATH expression ends with relationship. If this is a "to
- * many" relationship, a join is added and a column expression for the target entity
- * primary key. If this is a "to one" relationship, column expression for the source
- * foreign key is added.
+ * Processes case when an OBJ_PATH expression ends with relationship. If
+ * this is a "to many" relationship, a join is added and a column expression
+ * for the target entity primary key. If this is a "to one" relationship,
+ * column expression for the source foreign key is added.
*
* @since 3.0
*/
- protected void processRelTermination(
- ObjRelationship rel,
- JoinType joinType,
- String joinSplitAlias) throws IOException {
+ protected void processRelTermination(ObjRelationship rel, JoinType joinType, String joinSplitAlias)
+ throws IOException {
Iterator<DbRelationship> dbRels = rel.getDbRelationships().iterator();
@@ -493,8 +423,7 @@ public abstract class QueryAssemblerHelp
// it needs special handling
if (!dbRels.hasNext()) {
processRelTermination(dbRel, joinType, joinSplitAlias);
- }
- else {
+ } else {
// find and add joins ....
queryAssembler.dbRelationshipAdded(dbRel, joinType, joinSplitAlias);
}
@@ -502,17 +431,15 @@ public abstract class QueryAssemblerHelp
}
/**
- * Handles case when a DB_NAME expression ends with relationship. If this is a "to
- * many" relationship, a join is added and a column expression for the target entity
- * primary key. If this is a "to one" relationship, column expression for the source
- * foreign key is added.
+ * Handles case when a DB_NAME expression ends with relationship. If this is
+ * a "to many" relationship, a join is added and a column expression for the
+ * target entity primary key. If this is a "to one" relationship, column
+ * expression for the source foreign key is added.
*
* @since 3.0
*/
- protected void processRelTermination(
- DbRelationship rel,
- JoinType joinType,
- String joinSplitAlias) throws IOException {
+ protected void processRelTermination(DbRelationship rel, JoinType joinType, String joinSplitAlias)
+ throws IOException {
if (rel.isToMany()) {
// append joins
@@ -523,12 +450,8 @@ public abstract class QueryAssemblerHelp
List<DbJoin> joins = rel.getJoins();
if (joins.size() != 1) {
StringBuilder msg = new StringBuilder();
- msg
- .append("OBJ_PATH expressions are only supported ")
- .append("for a single-join relationships. ")
- .append("This relationship has ")
- .append(joins.size())
- .append(" joins.");
+ msg.append("OBJ_PATH expressions are only supported ").append("for a single-join relationships. ")
+ .append("This relationship has ").append(joins.size()).append(" joins.");
throw new CayenneRuntimeException(msg.toString());
}
@@ -542,19 +465,14 @@ public abstract class QueryAssemblerHelp
Collection<DbAttribute> pk = ent.getPrimaryKeys();
if (pk.size() != 1) {
StringBuilder msg = new StringBuilder();
- msg
- .append("DB_NAME expressions can only support ")
- .append("targets with a single column PK. ")
- .append("This entity has ")
- .append(pk.size())
- .append(" columns in primary key.");
+ msg.append("DB_NAME expressions can only support ").append("targets with a single column PK. ")
+ .append("This entity has ").append(pk.size()).append(" columns in primary key.");
throw new CayenneRuntimeException(msg.toString());
}
attribute = pk.iterator().next();
- }
- else {
+ } else {
attribute = join.getSource();
}
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -67,7 +67,7 @@ public class UpdateBatchQueryBuilder ext
}
DbAttribute attribute = updatedDbAttributes.get(i);
- query.append(strategy.quoteString(attribute.getName()));
+ query.append(strategy.quotedIdentifier(attribute.getName()));
query.append(" = ?");
}
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -33,23 +33,31 @@ class DefaultQuotingStrategy implements
this.endQuote = endQuote;
}
+ /**
+ * @deprecated since 3.2
+ */
+ @Deprecated
public String quoteString(String name) {
- return startQuote + name + endQuote;
+ return quotedIdentifier(name);
}
public String quoteFullyQualifiedName(DbEntity entity) {
- StringBuilder buf = new StringBuilder();
-
- if(entity.getCatalog() != null) {
- buf.append(quoteString(entity.getCatalog())).append(".");
- }
-
- if (entity.getSchema() != null) {
- buf.append(quoteString(entity.getSchema())).append(".");
+ return quotedIdentifier(entity.getCatalog(), entity.getSchema(), entity.getName());
+ }
+
+ public String quotedIdentifier(String... fqnParts) {
+
+ StringBuilder buffer = new StringBuilder();
+
+ for (String part : fqnParts) {
+
+ if (buffer.length() > 0) {
+ buffer.append(".");
+ }
+
+ buffer.append(startQuote).append(part).append(endQuote);
}
-
- buf.append(quoteString(entity.getName()));
-
- return buf.toString();
+
+ return buffer.toString();
}
}
\ No newline at end of file
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -335,7 +335,7 @@ public class JdbcAdapter implements DbAd
DbAttribute at = pkit.next();
- sqlBuffer.append(context.quoteString(at.getName()));
+ sqlBuffer.append(context.quotedIdentifier(at.getName()));
}
sqlBuffer.append(')');
}
@@ -359,7 +359,7 @@ public class JdbcAdapter implements DbAd
}
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
@@ -409,12 +409,12 @@ public class JdbcAdapter implements DbAd
Iterator<DbAttribute> it = columns.iterator();
DbAttribute first = it.next();
- buf.append(context.quoteString(first.getName()));
+ buf.append(context.quotedIdentifier(first.getName()));
while (it.hasNext()) {
DbAttribute next = it.next();
buf.append(", ");
- buf.append(context.quoteString(next.getName()));
+ buf.append(context.quotedIdentifier(next.getName()));
}
buf.append(")");
@@ -448,8 +448,8 @@ public class JdbcAdapter implements DbAd
} else
first = false;
- buf.append(context.quoteString(join.getSourceName()));
- refBuf.append(context.quoteString(join.getTargetName()));
+ buf.append(context.quotedIdentifier(join.getSourceName()));
+ refBuf.append(context.quotedIdentifier(join.getTargetName()));
}
buf.append(") REFERENCES ");
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/NoQuotingStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/NoQuotingStrategy.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/NoQuotingStrategy.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/NoQuotingStrategy.java Thu Nov 15 19:40:07 2012
@@ -25,11 +25,35 @@ import org.apache.cayenne.map.DbEntity;
*/
class NoQuotingStrategy implements QuotingStrategy {
+ /**
+ * @deprecated since 3.2
+ */
+ @Deprecated
public String quoteString(String name) {
- return name;
+ return quotedIdentifier(name);
}
public String quoteFullyQualifiedName(DbEntity entity) {
- return entity.getFullyQualifiedName();
+ return quotedIdentifier(entity.getCatalog(), entity.getSchema(), entity.getName());
+ }
+
+ public String quotedIdentifier(String... fqnParts) {
+
+ if (fqnParts.length == 1) {
+ return fqnParts[0];
+ }
+
+ StringBuilder buffer = new StringBuilder();
+
+ for (String part : fqnParts) {
+
+ if (buffer.length() > 0) {
+ buffer.append(".");
+ }
+
+ buffer.append(part);
+ }
+
+ return buffer.toString();
}
}
\ No newline at end of file
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -27,11 +27,26 @@ public interface QuotingStrategy {
/**
* Returns a properly quoted identifier.
+ *
+ * @deprecated use {@link #quotedIdentifier(String...)}
*/
+ @Deprecated
String quoteString(String identifier);
/**
- * Returns a properly quoted fully qualified name of DbEntity.
+ * Builds a fully qualified name from catalog, schema, name parts of
+ * DbEntity, inclosing them in quotations according to this strategy
+ * algorithm. Analog of toQuotedIdentifier(entity.getCatalog(),
+ * entity.getSchema(), entity.getName()).
*/
String quoteFullyQualifiedName(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);
}
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -144,7 +144,7 @@ public class DB2Adapter extends JdbcAdap
}
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())) {
@@ -193,7 +193,7 @@ public class DB2Adapter extends JdbcAdap
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/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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -41,7 +41,7 @@ public class DB2MergerFactory extends Me
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(" 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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -58,28 +58,22 @@ public class DB2PkGenerator extends Jdbc
try {
Statement st = con.createStatement();
try {
- String sql = "SELECT NEXTVAL FOR "
- + pkGeneratingSequenceName
- + " FROM SYSIBM.SYSDUMMY1";
+ String sql = "SELECT NEXTVAL FOR " + pkGeneratingSequenceName + " FROM SYSIBM.SYSDUMMY1";
adapter.getJdbcEventLogger().logQuery(sql, Collections.EMPTY_LIST);
ResultSet rs = st.executeQuery(sql);
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();
}
}
@@ -122,8 +116,7 @@ public class DB2PkGenerator extends Jdbc
tempEnt.setDataMap(dm);
tempEnt.setName(ent.getName());
name = sequenceName(tempEnt);
- }
- else {
+ } else {
name = sequenceName(ent);
}
if (sequences.contains(name)) {
@@ -145,7 +138,8 @@ public class DB2PkGenerator extends Jdbc
}
/**
- * 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<String> getExistingSequences(DataNode node) throws SQLException {
@@ -156,11 +150,8 @@ public class DB2PkGenerator extends Jdbc
Statement sel = con.createStatement();
try {
StringBuilder buffer = new StringBuilder();
- buffer
- .append("SELECT SEQNAME FROM SYSCAT.SEQUENCES ")
- .append("WHERE SEQNAME LIKE '")
- .append(_SEQUENCE_PREFIX)
- .append("%'");
+ buffer.append("SELECT SEQNAME FROM SYSCAT.SEQUENCES ").append("WHERE SEQNAME LIKE '")
+ .append(_SEQUENCE_PREFIX).append("%'");
String sql = buffer.toString();
adapter.getJdbcEventLogger().logQuery(sql, Collections.EMPTY_LIST);
@@ -171,16 +162,13 @@ public class DB2PkGenerator extends Jdbc
sequenceList.add(rs.getString(1));
}
return sequenceList;
- }
- finally {
+ } finally {
rs.close();
}
- }
- finally {
+ } finally {
sel.close();
}
- }
- finally {
+ } finally {
con.close();
}
}
@@ -192,26 +180,14 @@ public class DB2PkGenerator extends Jdbc
boolean status;
if (entity.getDataMap() != null && entity.getDataMap().isQuotingSQLIdentifiers()) {
status = true;
- }
- else {
+ } else {
status = false;
}
QuotingStrategy context = getAdapter().getQuotingStrategy(status);
String entName = entity.getName();
String seqName = _SEQUENCE_PREFIX + entName;
- if (entity.getSchema() != null && entity.getSchema().length() > 0) {
- if (context != null) {
- seqName = context.quoteString(entity.getSchema())
- + "."
- + context.quoteString(seqName);
- }
- else {
- seqName = entity.getSchema() + "." + seqName;
- }
- }
-
- return context.quoteString(seqName);
+ return context.quotedIdentifier(entity.getSchema(), seqName);
}
/**
@@ -226,15 +202,8 @@ public class DB2PkGenerator extends Jdbc
*/
protected String createSequenceString(DbEntity entity) {
StringBuilder buf = new StringBuilder();
- buf
- .append("CREATE SEQUENCE ")
- .append(sequenceName(entity))
- .append(" START WITH 200")
- .append(" INCREMENT BY ")
- .append(getPkCacheSize())
- .append(" NO MAXVALUE ")
- .append(" NO CYCLE ")
- .append(" CACHE ")
+ buf.append("CREATE SEQUENCE ").append(sequenceName(entity)).append(" START WITH 200").append(" INCREMENT BY ")
+ .append(getPkCacheSize()).append(" NO MAXVALUE ").append(" NO CYCLE ").append(" CACHE ")
.append(getPkCacheSize());
return buf.toString();
}
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -158,7 +158,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.quoteString(column.getName()));
+ sqlBuffer.append(context.quotedIdentifier(column.getName()));
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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -47,7 +47,7 @@ public class DerbyMergerFactory extends
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(" SET DATA TYPE ");
}
};
@@ -66,7 +66,7 @@ public class DerbyMergerFactory extends
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(" NOT NULL");
return Collections.singletonList(sqlBuffer.toString());
@@ -88,7 +88,7 @@ public class DerbyMergerFactory extends
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(" 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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -148,10 +148,10 @@ public class FrontBaseAdapter extends Jd
}
String type = types[0];
- buf.append(context.quoteString(at.getName())).append(' ').append(type);
+ buf.append(context.quotedIdentifier(at.getName())).append(' ').append(type);
- // Mapping LONGVARCHAR without length creates a column with lenght "1" which
- // is defintely not what we want...so just use something very large (1Gb seems
+ // 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
// to be the limit for FB)
if (at.getType() == Types.LONGVARCHAR) {
@@ -208,7 +208,7 @@ public class FrontBaseAdapter extends Jd
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/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=1409947&r1=1409946&r2=1409947&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 Thu Nov 15 19:40:07 2012
@@ -50,7 +50,7 @@ public class H2MergerFactory extends Mer
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(" ");
}
};
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLDBAdapter.java Thu Nov 15 19:40:07 2012
@@ -42,8 +42,9 @@ import org.apache.cayenne.query.Query;
import org.apache.cayenne.query.SQLAction;
/**
- * DbAdapter implementation for the <a href="http://hsqldb.sourceforge.net/"> HSQLDB RDBMS
- * </a>. Sample connection settings to use with HSQLDB are shown below:
+ * DbAdapter implementation for the <a href="http://hsqldb.sourceforge.net/">
+ * HSQLDB RDBMS </a>. Sample connection settings to use with HSQLDB are shown
+ * below:
*
* <pre>
* test-hsqldb.jdbc.username = test
@@ -54,55 +55,32 @@ import org.apache.cayenne.query.SQLActio
*/
public class HSQLDBAdapter extends JdbcAdapter {
- public HSQLDBAdapter(
- @Inject RuntimeProperties runtimeProperties,
+ public HSQLDBAdapter(@Inject RuntimeProperties runtimeProperties,
@Inject(Constants.SERVER_DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes,
@Inject(Constants.SERVER_USER_TYPES_LIST) List<ExtendedType> userExtendedTypes,
@Inject(Constants.SERVER_TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories) {
- super(
- runtimeProperties,
- defaultExtendedTypes,
- userExtendedTypes,
- extendedTypeFactories);
+ super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories);
}
/**
- * Generate fully-qualified name for 1.8 and on. Subclass generates unqualified name.
+ * Generate fully-qualified name for 1.8 and on. Subclass generates
+ * unqualified name.
*
* @since 1.2
*/
protected String getTableName(DbEntity entity) {
- QuotingStrategy context = getQuotingStrategy(entity
- .getDataMap()
- .isQuotingSQLIdentifiers());
+ QuotingStrategy context = getQuotingStrategy(entity.getDataMap().isQuotingSQLIdentifiers());
return context.quoteFullyQualifiedName(entity);
}
/**
- * Generate fully-qualified name for 1.8 and on. Subclass generates unqualified name.
- *
- * @since 1.2
- */
- protected String getSchemaName(DbEntity entity) {
- if (entity.getSchema() != null && entity.getSchema().length() > 0) {
- QuotingStrategy context = getQuotingStrategy(entity
- .getDataMap()
- .isQuotingSQLIdentifiers());
- return context.quoteString(entity.getSchema()) + ".";
- }
-
- return "";
- }
-
- /**
* Uses special action builder to create the right action.
*
* @since 1.2
*/
@Override
public SQLAction getAction(Query query, DataNode node) {
- return query
- .createSQLAction(new HSQLActionBuilder(this, node.getEntityResolver()));
+ return query.createSQLAction(new HSQLActionBuilder(this, node.getEntityResolver()));
}
/**
@@ -115,14 +93,12 @@ public class HSQLDBAdapter extends JdbcA
boolean status;
if (source.getDataMap() != null && source.getDataMap().isQuotingSQLIdentifiers()) {
status = true;
- }
- else {
+ } else {
status = false;
}
QuotingStrategy context = getQuotingStrategy(status);
if (columns == null || columns.isEmpty()) {
- throw new CayenneRuntimeException(
- "Can't create UNIQUE constraint - no columns specified.");
+ throw new CayenneRuntimeException("Can't create UNIQUE constraint - no columns specified.");
}
String srcName = getTableName(source);
@@ -132,23 +108,18 @@ public class HSQLDBAdapter extends JdbcA
buf.append("ALTER TABLE ").append(srcName);
buf.append(" ADD CONSTRAINT ");
- buf.append(context.quoteString(getSchemaName(source)));
- String name = "U_"
- + source.getName()
- + "_"
- + (long) (System.currentTimeMillis() / (Math.random() * 100000));
-
- buf.append(context.quoteString(name));
+ String name = "U_" + source.getName() + "_" + (long) (System.currentTimeMillis() / (Math.random() * 100000));
+ buf.append(context.quotedIdentifier(source.getSchema(), name));
buf.append(" UNIQUE (");
Iterator<DbAttribute> it = columns.iterator();
DbAttribute first = it.next();
- buf.append(context.quoteString(first.getName()));
+ buf.append(context.quotedIdentifier(first.getName()));
while (it.hasNext()) {
DbAttribute next = it.next();
buf.append(", ");
- buf.append(context.quoteString(next.getName()));
+ buf.append(context.quotedIdentifier(next.getName()));
}
buf.append(")");
@@ -167,8 +138,7 @@ public class HSQLDBAdapter extends JdbcA
if ((rel.getSourceEntity().getDataMap() != null)
&& rel.getSourceEntity().getDataMap().isQuotingSQLIdentifiers()) {
status = true;
- }
- else {
+ } else {
status = false;
}
QuotingStrategy context = getQuotingStrategy(status);
@@ -183,13 +153,13 @@ public class HSQLDBAdapter extends JdbcA
// hsqldb requires the ADD CONSTRAINT statement
buf.append(" ADD CONSTRAINT ");
- buf.append(getSchemaName((DbEntity) rel.getSourceEntity()));
- String name = "U_"
- + rel.getSourceEntity().getName()
- + "_"
+
+ String name = "U_" + rel.getSourceEntity().getName() + "_"
+ (long) (System.currentTimeMillis() / (Math.random() * 100000));
- buf.append(context.quoteString(name));
+ DbEntity sourceEntity = (DbEntity) rel.getSourceEntity();
+
+ buf.append(context.quotedIdentifier(sourceEntity.getSchema(), name));
buf.append(" FOREIGN KEY (");
boolean first = true;
@@ -197,12 +167,11 @@ public class HSQLDBAdapter extends JdbcA
if (!first) {
buf.append(", ");
refBuf.append(", ");
- }
- else
+ } else
first = false;
- buf.append(context.quoteString(join.getSourceName()));
- refBuf.append(context.quoteString(join.getTargetName()));
+ buf.append(context.quotedIdentifier(join.getSourceName()));
+ refBuf.append(context.quotedIdentifier(join.getTargetName()));
}
buf.append(") REFERENCES ");
@@ -235,15 +204,15 @@ public class HSQLDBAdapter extends JdbcA
@Override
public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) {
- // CAY-1095: if the column is type double, temporarily set the max length to 0 to
+ // CAY-1095: if the column is type double, temporarily set the max
+ // length to 0 to
// avoid adding precision information.
if (column.getType() == Types.DOUBLE && column.getMaxLength() > 0) {
int len = column.getMaxLength();
column.setMaxLength(0);
super.createTableAppendColumn(sqlBuffer, column);
column.setMaxLength(len);
- }
- else {
+ } else {
super.createTableAppendColumn(sqlBuffer, column);
}
}
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/hsqldb/HSQLMergerFactory.java Thu Nov 15 19:40:07 2012
@@ -47,7 +47,7 @@ public class HSQLMergerFactory extends M
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(" ");
}
};
@@ -66,7 +66,7 @@ public class HSQLMergerFactory extends M
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(" NULL");
return Collections.singletonList(sqlBuffer.toString());
Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresAdapter.java Thu Nov 15 19:40:07 2012
@@ -142,7 +142,7 @@ public class IngresAdapter extends JdbcA
}
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/ingres/IngresMergerFactory.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java?rev=1409947&r1=1409946&r2=1409947&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java (original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/dba/ingres/IngresMergerFactory.java Thu Nov 15 19:40:07 2012
@@ -53,7 +53,7 @@ public class IngresMergerFactory extends
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(" ");
}
};
@@ -72,7 +72,7 @@ public class IngresMergerFactory extends
buf.append("ALTER TABLE ");
buf.append(context.quoteFullyQualifiedName(getEntity()));
buf.append(" DROP COLUMN ");
- buf.append(context.quoteString(getColumn().getName()));
+ buf.append(context.quotedIdentifier(getColumn().getName()));
buf.append(" RESTRICT ");
return Collections.singletonList(buf.toString());
@@ -104,7 +104,7 @@ public class IngresMergerFactory extends
+ "_"
+ (long) (System.currentTimeMillis() / (Math.random() * 100000));
- buf.append(context.quoteString(name));
+ buf.append(context.quotedIdentifier(name));
buf.append(" FOREIGN KEY (");
boolean first = true;
@@ -116,8 +116,8 @@ public class IngresMergerFactory extends
else
first = false;
- buf.append(context.quoteString(join.getSourceName()));
- refBuf.append(context.quoteString(join.getTargetName()));
+ buf.append(context.quotedIdentifier(join.getSourceName()));
+ refBuf.append(context.quotedIdentifier(join.getTargetName()));
}
buf.append(") REFERENCES ");
@@ -162,7 +162,7 @@ public class IngresMergerFactory extends
sqlBuffer.append("ALTER TABLE ");
sqlBuffer.append(getEntity().getFullyQualifiedName());
sqlBuffer.append(" ALTER COLUMN ");
- sqlBuffer.append(context.quoteString(getColumn().getName()));
+ sqlBuffer.append(context.quotedIdentifier(getColumn().getName()));
sqlBuffer.append(" ");
sqlBuffer.append(adapter.externalTypesForJdbcType(getColumn().getType())[0]);
@@ -193,7 +193,7 @@ public class IngresMergerFactory extends
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(" ");
sqlBuffer.append(adapter.externalTypesForJdbcType(getColumn().getType())[0]);