You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mi...@apache.org on 2007/09/19 00:35:58 UTC
svn commit: r577090 - in
/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql:
DBDictionary.java PostgresDictionary.java
Author: mikedd
Date: Tue Sep 18 15:35:52 2007
New Revision: 577090
URL: http://svn.apache.org/viewvc?rev=577090&view=rev
Log:
OPENJPA-282 merging to 1.0.x branch.
Modified:
openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=577090&r1=577089&r2=577090&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java (original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java Tue Sep 18 15:35:52 2007
@@ -3059,7 +3059,7 @@
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 @@
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))
@@ -3105,6 +3105,16 @@
}
/**
+ * 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.
*/
private String getActionName(int action) {
@@ -3172,7 +3182,7 @@
*/
protected String getUniqueConstraintSQL(Unique unq) {
if (!supportsUniqueConstraints
- || (unq.isDeferred() && !supportsDeferredConstraints))
+ || (unq.isDeferred() && !supportsDeferredUniqueConstraints()))
return null;
StringBuffer buf = new StringBuffer();
@@ -3186,12 +3196,22 @@
append(")");
if (unq.isDeferred())
buf.append(" INITIALLY DEFERRED");
- if (supportsDeferredConstraints)
+ if (supportsDeferredUniqueConstraints())
buf.append(" DEFERRABLE");
if (unq.getName() != null
&& CONS_NAME_AFTER.equals(constraintNameMode))
buf.append(" CONSTRAINT ").append(unq.getName());
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;
}
/////////////////////
Modified: openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java?rev=577090&r1=577089&r2=577090&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java (original)
+++ openjpa/branches/1.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java Tue Sep 18 15:35:52 2007
@@ -94,10 +94,10 @@
// 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;
@@ -269,6 +269,11 @@
if (seq.getAllocate() > 1)
sql[0] += " CACHE " + seq.getAllocate();
return sql;
+ }
+
+ protected boolean supportsDeferredUniqueConstraints() {
+ // Postgres only supports deferred foreign key constraints.
+ return false;
}
protected String getSequencesSQL(String schemaName, String sequenceName) {