OPENJPA-282 merging to 1.0.x branch.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/1.0.x@577090 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2007-09-18 22:35:52 +00:00
parent aece331d8a
commit 972e71f970
2 changed files with 33 additions and 8 deletions

View File

@ -3059,7 +3059,7 @@ public class DBDictionary
return null; return null;
if (fk.getDeleteAction() == ForeignKey.ACTION_NONE) if (fk.getDeleteAction() == ForeignKey.ACTION_NONE)
return null; return null;
if (fk.isDeferred() && !supportsDeferredConstraints) if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints())
return null; return null;
if (!supportsDeleteAction(fk.getDeleteAction()) if (!supportsDeleteAction(fk.getDeleteAction())
|| !supportsUpdateAction(fk.getUpdateAction())) || !supportsUpdateAction(fk.getUpdateAction()))
@ -3096,7 +3096,7 @@ public class DBDictionary
buf.append(" ON UPDATE ").append(upAction); buf.append(" ON UPDATE ").append(upAction);
if (fk.isDeferred()) if (fk.isDeferred())
buf.append(" INITIALLY DEFERRED"); buf.append(" INITIALLY DEFERRED");
if (supportsDeferredConstraints) if (supportsDeferredForeignKeyConstraints())
buf.append(" DEFERRABLE"); buf.append(" DEFERRABLE");
if (fk.getName() != null if (fk.getName() != null
&& CONS_NAME_AFTER.equals(constraintNameMode)) && CONS_NAME_AFTER.equals(constraintNameMode))
@ -3104,6 +3104,16 @@ public class DBDictionary
return buf.toString(); return buf.toString();
} }
/**
* Whether or not this dictionary supports deferred foreign key constraints.
* This implementation returns {@link #supportsUniqueConstraints}.
*
* @since 1.1.0
*/
protected boolean supportsDeferredForeignKeyConstraints() {
return supportsDeferredConstraints;
}
/** /**
* Return the name of the given foreign key action. * Return the name of the given foreign key action.
*/ */
@ -3172,7 +3182,7 @@ public class DBDictionary
*/ */
protected String getUniqueConstraintSQL(Unique unq) { protected String getUniqueConstraintSQL(Unique unq) {
if (!supportsUniqueConstraints if (!supportsUniqueConstraints
|| (unq.isDeferred() && !supportsDeferredConstraints)) || (unq.isDeferred() && !supportsDeferredUniqueConstraints()))
return null; return null;
StringBuffer buf = new StringBuffer(); StringBuffer buf = new StringBuffer();
@ -3186,7 +3196,7 @@ public class DBDictionary
append(")"); append(")");
if (unq.isDeferred()) if (unq.isDeferred())
buf.append(" INITIALLY DEFERRED"); buf.append(" INITIALLY DEFERRED");
if (supportsDeferredConstraints) if (supportsDeferredUniqueConstraints())
buf.append(" DEFERRABLE"); buf.append(" DEFERRABLE");
if (unq.getName() != null if (unq.getName() != null
&& CONS_NAME_AFTER.equals(constraintNameMode)) && CONS_NAME_AFTER.equals(constraintNameMode))
@ -3194,6 +3204,16 @@ public class DBDictionary
return buf.toString(); return buf.toString();
} }
/**
* Whether or not this dictionary supports deferred unique constraints.
* This implementation returns {@link #supportsUniqueConstraints}.
*
* @since 1.1.0
*/
protected boolean supportsDeferredUniqueConstraints() {
return supportsDeferredConstraints;
}
///////////////////// /////////////////////
// Database metadata // Database metadata
///////////////////// /////////////////////

View File

@ -94,10 +94,10 @@ public class PostgresDictionary
// PostgreSQL requires double-escape for strings // PostgreSQL requires double-escape for strings
searchStringEscape = "\\\\"; searchStringEscape = "\\\\";
maxTableNameLength = 31; maxTableNameLength = 63;
maxColumnNameLength = 31; maxColumnNameLength = 63;
maxIndexNameLength = 31; maxIndexNameLength = 63;
maxConstraintNameLength = 31; maxConstraintNameLength = 63;
schemaCase = SCHEMA_CASE_LOWER; schemaCase = SCHEMA_CASE_LOWER;
rangePosition = RANGE_POST_LOCK; rangePosition = RANGE_POST_LOCK;
requiresAliasForSubselect = true; requiresAliasForSubselect = true;
@ -271,6 +271,11 @@ public class PostgresDictionary
return sql; return sql;
} }
protected boolean supportsDeferredUniqueConstraints() {
// Postgres only supports deferred foreign key constraints.
return false;
}
protected String getSequencesSQL(String schemaName, String sequenceName) { protected String getSequencesSQL(String schemaName, String sequenceName) {
if (schemaName == null && sequenceName == null) if (schemaName == null && sequenceName == null)
return allSequencesSQL; return allSequencesSQL;