From debc06d54e6a5ad8602161b31221a511f5ed968e Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 13 Jan 2016 11:31:09 -0600 Subject: [PATCH] HHH-10422 - Backport HHH-9983 to fix identity IDs using Oracle12cDialect in 5.0 --- .../java/org/hibernate/dialect/Dialect.java | 106 +----------------- .../hibernate/dialect/Teradata14Dialect.java | 19 ++-- .../hibernate/dialect/TeradataDialect.java | 20 ++-- .../identity/IdentityColumnSupport.java | 16 +-- .../Teradata14IdentityColumnSupport.java | 5 + 5 files changed, 35 insertions(+), 131 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 1b36e245fb..5df0d51a6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -25,8 +25,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import org.jboss.logging.Logger; - import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; @@ -106,6 +104,8 @@ import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.sql.ClobTypeDescriptor; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; +import org.jboss.logging.Logger; + /** * Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility * with different systems. Subclasses should provide a public default constructor that register a set of type @@ -751,108 +751,6 @@ public abstract class Dialect implements ConversionContext { return new IdentityColumnSupportImpl(); } - /** - * Does this dialect support identity column key generation? - * - * @return True if IDENTITY columns are supported; false otherwise. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public boolean supportsIdentityColumns() { - return getIdentityColumnSupport().supportsIdentityColumns(); - } - - /** - * Does the dialect support some form of inserting and selecting - * the generated IDENTITY value all in the same statement. - * - * @return True if the dialect supports selecting the just - * generated IDENTITY in the insert statement. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public boolean supportsInsertSelectIdentity() { - return getIdentityColumnSupport().supportsInsertSelectIdentity(); - } - - /** - * Whether this dialect have an Identity clause added to the data type or a - * completely separate identity data type - * - * @return boolean - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public boolean hasDataTypeInIdentityColumn() { - return getIdentityColumnSupport().hasDataTypeInIdentityColumn(); - } - - /** - * Provided we {@link #supportsInsertSelectIdentity}, then attach the - * "select identity" clause to the insert statement. - *

- * Note, if {@link #supportsInsertSelectIdentity} == false then - * the insert-string should be returned without modification. - * - * @param insertString The insert command - * @return The insert command with any necessary identity select - * clause attached. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public String appendIdentitySelectToInsert(String insertString) { - return getIdentityColumnSupport().appendIdentitySelectToInsert( insertString ); - } - - /** - * Get the select command to use to retrieve the last generated IDENTITY - * value for a particular table - * - * @param table The table into which the insert was done - * @param column The PK column. - * @param type The {@link java.sql.Types} type code. - * @return The appropriate select command - * @throws MappingException If IDENTITY generation is not supported. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public String getIdentitySelectString(String table, String column, int type) throws MappingException { - return getIdentityColumnSupport().getIdentitySelectString( table, column, type ); - } - - /** - * The syntax used during DDL to define a column as being an IDENTITY of - * a particular type. - * - * @param type The {@link java.sql.Types} type code. - * @return The appropriate DDL fragment. - * @throws MappingException If IDENTITY generation is not supported. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public String getIdentityColumnString(int type) throws MappingException { - return getIdentityColumnSupport().getIdentityColumnString( type ); - } - - /** - * The keyword used to insert a generated value into an identity column (or null). - * Need if the dialect does not support inserts that specify no column values. - * - * @return The appropriate keyword. - * - * @deprecated use {@link IdentityColumnSupport} method instead - */ - @Deprecated - public String getIdentityInsertString() { - return getIdentityColumnSupport().getIdentityInsertString(); - } - // SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Teradata14Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Teradata14Dialect.java index 25e7f1a75a..c7eb3ce7dc 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Teradata14Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Teradata14Dialect.java @@ -6,6 +6,13 @@ */ package org.hibernate.dialect; +import java.sql.CallableStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; +import java.util.Iterator; +import java.util.Map; + import org.hibernate.HibernateException; import org.hibernate.LockOptions; import org.hibernate.boot.Metadata; @@ -24,13 +31,6 @@ import org.hibernate.tool.schema.internal.StandardIndexExporter; import org.hibernate.tool.schema.spi.Exporter; import org.hibernate.type.StandardBasicTypes; -import java.sql.CallableStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Iterator; -import java.util.Map; - /** * A dialect for the Teradata database */ @@ -57,11 +57,6 @@ public class Teradata14Dialect extends TeradataDialect { TeraIndexExporter = new TeradataIndexExporter( this ); } - @Override - public boolean supportsIdentityColumns() { - return true; - } - @Override public String getAddColumnString() { return "Add"; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java index d8f99cf9f5..ed157d7578 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java @@ -105,18 +105,17 @@ public class TeradataDialect extends Dialect implements IdTableSupport { * * @return empty string ... Teradata does not support FOR UPDATE syntax */ + @Override public String getForUpdateString() { return ""; } - public boolean supportsIdentityColumns() { - return false; - } - + @Override public boolean supportsSequences() { return false; } + @Override public String getAddColumnString() { return "Add Column"; } @@ -171,22 +170,27 @@ public class TeradataDialect extends Dialect implements IdTableSupport { return super.getTypeName( code, length, p, s ); } + @Override public boolean supportsCascadeDelete() { return false; } + @Override public boolean supportsCircularCascadeDeleteConstraints() { return false; } + @Override public boolean areStringComparisonsCaseInsensitive() { return true; } + @Override public boolean supportsEmptyInList() { return false; } + @Override public String getSelectClauseNullString(int sqlType) { String v = "null"; @@ -232,29 +236,31 @@ public class TeradataDialect extends Dialect implements IdTableSupport { return v; } + @Override public String getCreateMultisetTableString() { return "create multiset table "; } + @Override public boolean supportsLobValueChangePropogation() { return false; } + @Override public boolean doesReadCommittedCauseWritersToBlockReaders() { return true; } + @Override public boolean doesRepeatableReadCauseReadersToBlockWriters() { return true; } + @Override public boolean supportsBindAsCallableArgument() { return false; } - /* (non-Javadoc) - * @see org.hibernate.dialect.Dialect#getInExpressionCountLimit() - */ @Override public int getInExpressionCountLimit() { return PARAM_LIST_SIZE_LIMIT; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/identity/IdentityColumnSupport.java b/hibernate-core/src/main/java/org/hibernate/dialect/identity/IdentityColumnSupport.java index c3bf2f2451..e63592fbe5 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/identity/IdentityColumnSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/identity/IdentityColumnSupport.java @@ -23,7 +23,7 @@ public interface IdentityColumnSupport { * * @return True if IDENTITY columns are supported; false otherwise. */ - public boolean supportsIdentityColumns(); + boolean supportsIdentityColumns(); /** * Does the dialect support some form of inserting and selecting @@ -32,7 +32,7 @@ public interface IdentityColumnSupport { * @return True if the dialect supports selecting the just * generated IDENTITY in the insert statement. */ - public boolean supportsInsertSelectIdentity(); + boolean supportsInsertSelectIdentity(); /** * Whether this dialect have an Identity clause added to the data type or a @@ -40,7 +40,7 @@ public interface IdentityColumnSupport { * * @return boolean */ - public boolean hasDataTypeInIdentityColumn(); + boolean hasDataTypeInIdentityColumn(); /** * Provided we {@link #supportsInsertSelectIdentity}, then attach the @@ -54,7 +54,7 @@ public interface IdentityColumnSupport { * @return The insert command with any necessary identity select * clause attached. */ - public String appendIdentitySelectToInsert(String insertString); + String appendIdentitySelectToInsert(String insertString); /** * Get the select command to use to retrieve the last generated IDENTITY @@ -68,7 +68,7 @@ public interface IdentityColumnSupport { * * @throws MappingException If IDENTITY generation is not supported. */ - public String getIdentitySelectString(String table, String column, int type) throws MappingException; + String getIdentitySelectString(String table, String column, int type) throws MappingException; /** @@ -81,7 +81,7 @@ public interface IdentityColumnSupport { * * @throws MappingException If IDENTITY generation is not supported. */ - public String getIdentityColumnString(int type) throws MappingException; + String getIdentityColumnString(int type) throws MappingException; /** @@ -90,7 +90,7 @@ public interface IdentityColumnSupport { * * @return The appropriate keyword. */ - public String getIdentityInsertString(); + String getIdentityInsertString(); /** * The Delegate for dealing with IDENTITY columns using JDBC3 getGeneratedKeys @@ -100,7 +100,7 @@ public interface IdentityColumnSupport { * * @return the dialect specific GetGeneratedKeys delegate */ - public GetGeneratedKeysDelegate buildGetGeneratedKeysDelegate( + GetGeneratedKeysDelegate buildGetGeneratedKeysDelegate( PostInsertIdentityPersister persister, Dialect dialect); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/identity/Teradata14IdentityColumnSupport.java b/hibernate-core/src/main/java/org/hibernate/dialect/identity/Teradata14IdentityColumnSupport.java index c0d6c4483e..c6d2b79ac8 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/identity/Teradata14IdentityColumnSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/identity/Teradata14IdentityColumnSupport.java @@ -10,6 +10,11 @@ package org.hibernate.dialect.identity; * @author Andrea Boriero */ public class Teradata14IdentityColumnSupport extends IdentityColumnSupportImpl { + @Override + public boolean supportsIdentityColumns() { + return true; + } + @Override public String getIdentityColumnString(int type) { return "generated by default as identity not null";