diff --git a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java index 7551bec812..00c6141bda 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java @@ -13,7 +13,6 @@ import java.sql.SQLException; import java.sql.Types; import java.util.Properties; -import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; import org.hibernate.MappingException; @@ -22,7 +21,6 @@ import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.Namespace; import org.hibernate.boot.model.relational.QualifiedName; import org.hibernate.boot.model.relational.QualifiedNameParser; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.Size; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.engine.jdbc.internal.FormatStyle; @@ -389,20 +387,6 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera } - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return new String[] { - dialect.getCreateTableString() - + ' ' + tableName + " ( " - + segmentColumnName + ' ' + dialect.getTypeName( Types.VARCHAR, Size.length(keySize) ) + ", " - + valueColumnName + ' ' + dialect.getTypeName( Types.INTEGER ) - + " )" + dialect.getTableTypeString() - }; - } - - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return new String[] {dialect.getDropTableString( tableName )}; - } - public Object generatorKey() { return tableName; } diff --git a/hibernate-core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java index 32e3aee387..2c818bbb2d 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/PersistentIdentifierGenerator.java @@ -58,32 +58,6 @@ public interface PersistentIdentifierGenerator extends OptimizableGenerator { */ String IDENTIFIER_NORMALIZER = "identifier_normalizer"; - /** - * The SQL required to create the underlying database objects. - * - * @param dialect The dialect against which to generate the create command(s) - * - * @return The create command(s) - * - * @throws HibernateException problem creating the create command(s) - * @deprecated Utilize the ExportableProducer contract instead - */ - @Deprecated - String[] sqlCreateStrings(Dialect dialect) throws HibernateException; - - /** - * The SQL required to remove the underlying database objects. - * - * @param dialect The dialect against which to generate the drop command(s) - * - * @return The drop command(s) - * - * @throws HibernateException problem creating the drop command(s) - * @deprecated Utilize the ExportableProducer contract instead - */ - @Deprecated - String[] sqlDropStrings(Dialect dialect) throws HibernateException; - /** * Return a key unique to the underlying database objects. Prevents us from * trying to create/remove them multiple times. diff --git a/hibernate-core/src/main/java/org/hibernate/id/SequenceGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/SequenceGenerator.java index a52bd9c5c9..4fbee871a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/SequenceGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/SequenceGenerator.java @@ -156,17 +156,6 @@ public class SequenceGenerator return IdentifierGeneratorHelper.getIntegralDataTypeHolder( identifierType.getReturnedClass() ); } - @Override - @SuppressWarnings( {"deprecation"}) - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, 1, 1 ); - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName ); - } - @Override public boolean supportsBulkInsertionIdentifierGeneration() { return true; diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java index 2e256864c9..dcb907e14f 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/DatabaseStructure.java @@ -7,7 +7,6 @@ package org.hibernate.id.enhanced; import org.hibernate.boot.model.relational.ExportableProducer; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.SharedSessionContractImplementor; /** @@ -58,20 +57,6 @@ public interface DatabaseStructure extends ExportableProducer { */ void prepare(Optimizer optimizer); - /** - * Commands needed to create the underlying structures. - * @param dialect The database dialect being used. - * @return The creation commands. - */ - String[] sqlCreateStrings(Dialect dialect); - - /** - * Commands needed to drop the underlying structures. - * @param dialect The database dialect being used. - * @return The drop commands. - */ - String[] sqlDropStrings(Dialect dialect); - /** * Is the structure physically a sequence? * diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java index e7a67b96df..a98d22e619 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStructure.java @@ -11,12 +11,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import org.hibernate.AssertionFailure; -import org.hibernate.HibernateException; import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.Namespace; import org.hibernate.boot.model.relational.QualifiedName; import org.hibernate.boot.model.relational.Sequence; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.IdentifierGeneratorHelper; @@ -147,16 +145,6 @@ public class SequenceStructure implements DatabaseStructure { this.sql = database.getJdbcEnvironment().getDialect().getSequenceSupport().getSequenceNextValString( sequenceName ); } - @Override - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, initialValue, getSourceIncrementSize() ); - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName ); - } - @Override public boolean isPhysicalSequence() { return true; diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java index 691467c46b..3e5f080f15 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java @@ -11,7 +11,6 @@ import java.util.Properties; import org.hibernate.HibernateException; import org.hibernate.MappingException; -import org.hibernate.boot.SchemaAutoTooling; import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.QualifiedName; @@ -539,16 +538,6 @@ public class SequenceStyleGenerator return databaseStructure.getName(); } - @Override - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return databaseStructure.sqlCreateStrings( dialect ); - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return databaseStructure.sqlDropStrings( dialect ); - } - // BulkInsertionCapableIdentifierGenerator implementation ~~~~~~~~~~~~~~~~~ diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java index deaf88df0a..ec61980c95 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java @@ -15,7 +15,6 @@ import java.util.Collections; import java.util.Map; import java.util.Properties; -import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; import org.hibernate.MappingException; @@ -682,21 +681,6 @@ public class TableGenerator implements PersistentIdentifierGenerator { } } - @Override - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return new String[] { - dialect.getCreateTableString() + ' ' + renderedTableName + " ( " - + segmentColumnName + ' ' + dialect.getTypeName( Types.VARCHAR, Size.length(segmentValueLength) ) + " not null " - + ", " + valueColumnName + ' ' + dialect.getTypeName( Types.BIGINT ) - + ", primary key ( " + segmentColumnName + " ) )" + dialect.getTableTypeString() - }; - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return new String[] { dialect.getDropTableString( renderedTableName ) }; - } - @Override public void registerExportables(Database database) { final Dialect dialect = database.getJdbcEnvironment().getDialect(); diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java index 23559472e6..3bb3a6cb1e 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java @@ -10,10 +10,8 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Types; import org.hibernate.AssertionFailure; -import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; import org.hibernate.boot.model.naming.Identifier; @@ -226,19 +224,6 @@ public class TableStructure implements DatabaseStructure { } } - @Override - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - return new String[] { - dialect.getCreateTableString() + " " + tableNameText + " ( " + valueColumnNameText + " " + dialect.getTypeName( Types.BIGINT ) + " )", - "insert into " + tableNameText + " values ( " + initialValue + " )" - }; - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - return new String[] { dialect.getDropTableString( tableNameText ) }; - } - @Override public boolean isPhysicalSequence() { return false; diff --git a/hibernate-envers/hibernate-envers.gradle b/hibernate-envers/hibernate-envers.gradle index 985f7b885d..8d5442ee2f 100644 --- a/hibernate-envers/hibernate-envers.gradle +++ b/hibernate-envers/hibernate-envers.gradle @@ -21,6 +21,7 @@ dependencies { annotationProcessor project( ':hibernate-jpamodelgen' ) testImplementation project( ':hibernate-testing' ) + testImplementation libraries.assertj } test { diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/OrderedSequenceStructure.java b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/OrderedSequenceStructure.java index 13004f05e6..3ff17fb777 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/OrderedSequenceStructure.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/enhanced/OrderedSequenceStructure.java @@ -6,7 +6,6 @@ */ package org.hibernate.envers.enhanced; -import org.hibernate.HibernateException; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.QualifiedName; @@ -36,18 +35,6 @@ public class OrderedSequenceStructure extends SequenceStructure { this.sequenceObject = new OrderedSequence(); } - @Override - public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { - // delegate to auxiliary object - return sequenceObject.sqlCreateStrings( dialect ); - } - - @Override - public String[] sqlDropStrings(Dialect dialect) throws HibernateException { - // delegate to auxiliary object - return sequenceObject.sqlDropStrings( dialect ); - } - @Override protected void buildSequence(Database database) { database.addAuxiliaryDatabaseObject( sequenceObject ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/MonotonicRevisionNumberTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/MonotonicRevisionNumberTest.java index 26221651af..fe84e7e9a7 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/MonotonicRevisionNumberTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/reventity/MonotonicRevisionNumberTest.java @@ -6,6 +6,12 @@ */ package org.hibernate.orm.test.envers.integration.reventity; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Optional; + +import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; +import org.hibernate.boot.model.relational.Database; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.envers.enhanced.OrderedSequenceGenerator; import org.hibernate.envers.enhanced.SequenceIdRevisionEntity; @@ -35,10 +41,16 @@ public class MonotonicRevisionNumberTest extends BaseEnversFunctionalTestCase { EntityPersister persister = sessionFactory().getEntityPersister( SequenceIdRevisionEntity.class.getName() ); IdentifierGenerator generator = persister.getIdentifierGenerator(); Assert.assertTrue( OrderedSequenceGenerator.class.isInstance( generator ) ); - OrderedSequenceGenerator seqGenerator = (OrderedSequenceGenerator) generator; + + Database database = metadata().getDatabase(); + Optional sequenceOptional = database.getAuxiliaryDatabaseObjects().stream() + .filter( o -> "REVISION_GENERATOR".equals( o.getExportIdentifier() ) ) + .findFirst(); + assertThat( sequenceOptional ).isPresent(); + String[] sqlCreateStrings = sequenceOptional.get().sqlCreateStrings( database.getDialect() ); Assert.assertTrue( "Oracle sequence needs to be ordered in RAC environment.", - seqGenerator.sqlCreateStrings( getDialect() )[0].toLowerCase().endsWith( " order" ) + sqlCreateStrings[0].toLowerCase().endsWith( " order" ) ); } }