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;
if (fk.getDeleteAction() == ForeignKey.ACTION_NONE)
return null;
if (fk.isDeferred() && !supportsDeferredConstraints)
if (fk.isDeferred() && !supportsDeferredForeignKeyConstraints())
return null;
if (!supportsDeleteAction(fk.getDeleteAction())
|| !supportsUpdateAction(fk.getUpdateAction()))
@ -3096,7 +3096,7 @@ public class DBDictionary
buf.append(" ON UPDATE ").append(upAction);
if (fk.isDeferred())
buf.append(" INITIALLY DEFERRED");
if (supportsDeferredConstraints)
if (supportsDeferredForeignKeyConstraints())
buf.append(" DEFERRABLE");
if (fk.getName() != null
&& CONS_NAME_AFTER.equals(constraintNameMode))
@ -3104,6 +3104,16 @@ public class DBDictionary
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.
*/
@ -3172,7 +3182,7 @@ public class DBDictionary
*/
protected String getUniqueConstraintSQL(Unique unq) {
if (!supportsUniqueConstraints
|| (unq.isDeferred() && !supportsDeferredConstraints))
|| (unq.isDeferred() && !supportsDeferredUniqueConstraints()))
return null;
StringBuffer buf = new StringBuffer();
@ -3186,7 +3196,7 @@ public class DBDictionary
append(")");
if (unq.isDeferred())
buf.append(" INITIALLY DEFERRED");
if (supportsDeferredConstraints)
if (supportsDeferredUniqueConstraints())
buf.append(" DEFERRABLE");
if (unq.getName() != null
&& CONS_NAME_AFTER.equals(constraintNameMode))
@ -3194,6 +3204,16 @@ public class DBDictionary
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
/////////////////////

View File

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