HHH-14921 Remove a few unused SQL generation methods in identifier generators
They are getting in the way of changes related to the default schema
This commit is contained in:
parent
cc13379c77
commit
16524e2f67
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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?
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 ~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,6 +21,7 @@ dependencies {
|
|||
annotationProcessor project( ':hibernate-jpamodelgen' )
|
||||
|
||||
testImplementation project( ':hibernate-testing' )
|
||||
testImplementation libraries.assertj
|
||||
}
|
||||
|
||||
test {
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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<AuxiliaryDatabaseObject> 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" )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue