Use SequenceSupport everywhere instead of deprecated methods of Dialect

This commit is contained in:
gavinking 2020-01-28 18:00:20 +01:00 committed by Steve Ebersole
parent f6eaaca824
commit 4f5b37c9c4
9 changed files with 19 additions and 17 deletions

View File

@ -79,14 +79,14 @@ public class MariaDBDialect extends MySQLDialect {
@Override
public String getQuerySequencesString() {
return supportsSequences()
return getSequenceSupport().supportsSequences()
? "select table_name from information_schema.TABLES where table_type='SEQUENCE'"
: super.getQuerySequencesString(); //fancy way to write "null"
}
@Override
public SequenceInformationExtractor getSequenceInformationExtractor() {
return supportsSequences()
return getSequenceSupport().supportsSequences()
? SequenceInformationExtractorMariaDBDatabaseImpl.INSTANCE
: super.getSequenceInformationExtractor();
}

View File

@ -146,12 +146,12 @@ public class SequenceGenerator
@Override
@SuppressWarnings( {"deprecation"})
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
return dialect.getCreateSequenceStrings( sequenceName, 1, 1 );
return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, 1, 1 );
}
@Override
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
return dialect.getDropSequenceStrings( sequenceName );
return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName );
}
@Override
@ -189,6 +189,6 @@ public class SequenceGenerator
sequence.getName(),
dialect
);
this.sql = jdbcEnvironment.getDialect().getSequenceNextValString( sequenceName );
this.sql = jdbcEnvironment.getDialect().getSequenceSupport().getSequenceNextValString( sequenceName );
}
}

View File

@ -141,17 +141,17 @@ public class SequenceStructure implements DatabaseStructure {
@Override
public void registerExportables(Database database) {
buildSequence( database );
this.sql = database.getJdbcEnvironment().getDialect().getSequenceNextValString( sequenceName );
this.sql = database.getJdbcEnvironment().getDialect().getSequenceSupport().getSequenceNextValString( sequenceName );
}
@Override
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
return dialect.getCreateSequenceStrings( sequenceName, initialValue, getSourceIncrementSize() );
return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, initialValue, getSourceIncrementSize() );
}
@Override
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
return dialect.getDropSequenceStrings( sequenceName );
return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName );
}
@Override

View File

@ -271,8 +271,9 @@ public class SequenceStyleGenerator
final String optimizationStrategy = determineOptimizationStrategy( params, incrementSize );
incrementSize = determineAdjustedIncrementSize( optimizationStrategy, incrementSize );
if ( dialect.supportsSequences() && !forceTableUse ) {
if ( !dialect.supportsPooledSequences() && OptimizerFactory.isPooledOptimizer( optimizationStrategy ) ) {
if ( dialect.getSequenceSupport().supportsSequences() && !forceTableUse ) {
if ( !dialect.getSequenceSupport().supportsPooledSequences()
&& OptimizerFactory.isPooledOptimizer( optimizationStrategy ) ) {
forceTableUse = true;
LOG.forcingTableUse();
}
@ -486,7 +487,8 @@ public class SequenceStyleGenerator
}
protected boolean isPhysicalSequence(JdbcEnvironment jdbcEnvironment, boolean forceTableUse) {
return jdbcEnvironment.getDialect().supportsSequences() && !forceTableUse;
return jdbcEnvironment.getDialect().getSequenceSupport().supportsSequences()
&& !forceTableUse;
}
protected DatabaseStructure buildSequenceStructure(

View File

@ -25,7 +25,7 @@ public class StandardSequenceExporter implements Exporter<Sequence> {
@Override
public String[] getSqlCreateStrings(Sequence sequence, Metadata metadata) {
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
return dialect.getCreateSequenceStrings(
return dialect.getSequenceSupport().getCreateSequenceStrings(
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
sequence.getName(),
jdbcEnvironment.getDialect()
@ -38,7 +38,7 @@ public class StandardSequenceExporter implements Exporter<Sequence> {
@Override
public String[] getSqlDropStrings(Sequence sequence, Metadata metadata) {
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
return dialect.getDropSequenceStrings(
return dialect.getSequenceSupport().getDropSequenceStrings(
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
sequence.getName(),
jdbcEnvironment.getDialect()

View File

@ -77,7 +77,7 @@ public class OrderedSequenceStructure extends SequenceStructure {
@Override
public String[] sqlCreateStrings(Dialect dialect) {
final String[] createStrings = dialect.getCreateSequenceStrings(
final String[] createStrings = dialect.getSequenceSupport().getCreateSequenceStrings(
getName(),
getInitialValue(),
getSourceIncrementSize()

View File

@ -64,7 +64,7 @@ public class OrderSequenceGenerationTest extends BaseEnversJPAFunctionalTestCase
@Test
public void testCreateSequenceExportScripts() throws Exception {
final String[] createStrings = getDialect().getCreateSequenceStrings( "REVISION_GENERATOR", 1, 1 );
final String[] createStrings = getDialect().getSequenceSupport().getCreateSequenceStrings( "REVISION_GENERATOR", 1, 1 );
final String content = new String( Files.readAllBytes( createSchema.toPath() ) ).toLowerCase();
for ( int i = 0; i < createStrings.length; ++i ) {
if ( getDialect() instanceof Oracle8iDialect ) {

View File

@ -21,7 +21,7 @@ import org.hibernate.dialect.SybaseDialect;
abstract public class DialectChecks {
public static class SupportsSequences implements DialectCheck {
public boolean isMatch(Dialect dialect) {
return dialect.supportsSequences();
return dialect.getSequenceSupport().supportsSequences();
}
}

View File

@ -18,7 +18,7 @@ import org.hibernate.dialect.Dialect;
abstract public class DialectFeatureChecks {
public static class SupportsSequences implements DialectFeatureCheck {
public boolean apply(Dialect dialect) {
return dialect.supportsSequences();
return dialect.getSequenceSupport().supportsSequences();
}
}