Use SequenceSupport everywhere instead of deprecated methods of Dialect
This commit is contained in:
parent
f6eaaca824
commit
4f5b37c9c4
|
@ -79,14 +79,14 @@ public class MariaDBDialect extends MySQLDialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return supportsSequences()
|
return getSequenceSupport().supportsSequences()
|
||||||
? "select table_name from information_schema.TABLES where table_type='SEQUENCE'"
|
? "select table_name from information_schema.TABLES where table_type='SEQUENCE'"
|
||||||
: super.getQuerySequencesString(); //fancy way to write "null"
|
: super.getQuerySequencesString(); //fancy way to write "null"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
||||||
return supportsSequences()
|
return getSequenceSupport().supportsSequences()
|
||||||
? SequenceInformationExtractorMariaDBDatabaseImpl.INSTANCE
|
? SequenceInformationExtractorMariaDBDatabaseImpl.INSTANCE
|
||||||
: super.getSequenceInformationExtractor();
|
: super.getSequenceInformationExtractor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,12 @@ public class SequenceGenerator
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( {"deprecation"})
|
@SuppressWarnings( {"deprecation"})
|
||||||
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
|
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
|
||||||
return dialect.getCreateSequenceStrings( sequenceName, 1, 1 );
|
return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
|
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
|
||||||
return dialect.getDropSequenceStrings( sequenceName );
|
return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,6 +189,6 @@ public class SequenceGenerator
|
||||||
sequence.getName(),
|
sequence.getName(),
|
||||||
dialect
|
dialect
|
||||||
);
|
);
|
||||||
this.sql = jdbcEnvironment.getDialect().getSequenceNextValString( sequenceName );
|
this.sql = jdbcEnvironment.getDialect().getSequenceSupport().getSequenceNextValString( sequenceName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,17 +141,17 @@ public class SequenceStructure implements DatabaseStructure {
|
||||||
@Override
|
@Override
|
||||||
public void registerExportables(Database database) {
|
public void registerExportables(Database database) {
|
||||||
buildSequence( database );
|
buildSequence( database );
|
||||||
this.sql = database.getJdbcEnvironment().getDialect().getSequenceNextValString( sequenceName );
|
this.sql = database.getJdbcEnvironment().getDialect().getSequenceSupport().getSequenceNextValString( sequenceName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
|
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException {
|
||||||
return dialect.getCreateSequenceStrings( sequenceName, initialValue, getSourceIncrementSize() );
|
return dialect.getSequenceSupport().getCreateSequenceStrings( sequenceName, initialValue, getSourceIncrementSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
|
public String[] sqlDropStrings(Dialect dialect) throws HibernateException {
|
||||||
return dialect.getDropSequenceStrings( sequenceName );
|
return dialect.getSequenceSupport().getDropSequenceStrings( sequenceName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -271,8 +271,9 @@ public class SequenceStyleGenerator
|
||||||
final String optimizationStrategy = determineOptimizationStrategy( params, incrementSize );
|
final String optimizationStrategy = determineOptimizationStrategy( params, incrementSize );
|
||||||
incrementSize = determineAdjustedIncrementSize( optimizationStrategy, incrementSize );
|
incrementSize = determineAdjustedIncrementSize( optimizationStrategy, incrementSize );
|
||||||
|
|
||||||
if ( dialect.supportsSequences() && !forceTableUse ) {
|
if ( dialect.getSequenceSupport().supportsSequences() && !forceTableUse ) {
|
||||||
if ( !dialect.supportsPooledSequences() && OptimizerFactory.isPooledOptimizer( optimizationStrategy ) ) {
|
if ( !dialect.getSequenceSupport().supportsPooledSequences()
|
||||||
|
&& OptimizerFactory.isPooledOptimizer( optimizationStrategy ) ) {
|
||||||
forceTableUse = true;
|
forceTableUse = true;
|
||||||
LOG.forcingTableUse();
|
LOG.forcingTableUse();
|
||||||
}
|
}
|
||||||
|
@ -486,7 +487,8 @@ public class SequenceStyleGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isPhysicalSequence(JdbcEnvironment jdbcEnvironment, boolean forceTableUse) {
|
protected boolean isPhysicalSequence(JdbcEnvironment jdbcEnvironment, boolean forceTableUse) {
|
||||||
return jdbcEnvironment.getDialect().supportsSequences() && !forceTableUse;
|
return jdbcEnvironment.getDialect().getSequenceSupport().supportsSequences()
|
||||||
|
&& !forceTableUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DatabaseStructure buildSequenceStructure(
|
protected DatabaseStructure buildSequenceStructure(
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class StandardSequenceExporter implements Exporter<Sequence> {
|
||||||
@Override
|
@Override
|
||||||
public String[] getSqlCreateStrings(Sequence sequence, Metadata metadata) {
|
public String[] getSqlCreateStrings(Sequence sequence, Metadata metadata) {
|
||||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
||||||
return dialect.getCreateSequenceStrings(
|
return dialect.getSequenceSupport().getCreateSequenceStrings(
|
||||||
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
|
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
|
||||||
sequence.getName(),
|
sequence.getName(),
|
||||||
jdbcEnvironment.getDialect()
|
jdbcEnvironment.getDialect()
|
||||||
|
@ -38,7 +38,7 @@ public class StandardSequenceExporter implements Exporter<Sequence> {
|
||||||
@Override
|
@Override
|
||||||
public String[] getSqlDropStrings(Sequence sequence, Metadata metadata) {
|
public String[] getSqlDropStrings(Sequence sequence, Metadata metadata) {
|
||||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
||||||
return dialect.getDropSequenceStrings(
|
return dialect.getSequenceSupport().getDropSequenceStrings(
|
||||||
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
|
jdbcEnvironment.getQualifiedObjectNameFormatter().format(
|
||||||
sequence.getName(),
|
sequence.getName(),
|
||||||
jdbcEnvironment.getDialect()
|
jdbcEnvironment.getDialect()
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class OrderedSequenceStructure extends SequenceStructure {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] sqlCreateStrings(Dialect dialect) {
|
public String[] sqlCreateStrings(Dialect dialect) {
|
||||||
final String[] createStrings = dialect.getCreateSequenceStrings(
|
final String[] createStrings = dialect.getSequenceSupport().getCreateSequenceStrings(
|
||||||
getName(),
|
getName(),
|
||||||
getInitialValue(),
|
getInitialValue(),
|
||||||
getSourceIncrementSize()
|
getSourceIncrementSize()
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class OrderSequenceGenerationTest extends BaseEnversJPAFunctionalTestCase
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateSequenceExportScripts() throws Exception {
|
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();
|
final String content = new String( Files.readAllBytes( createSchema.toPath() ) ).toLowerCase();
|
||||||
for ( int i = 0; i < createStrings.length; ++i ) {
|
for ( int i = 0; i < createStrings.length; ++i ) {
|
||||||
if ( getDialect() instanceof Oracle8iDialect ) {
|
if ( getDialect() instanceof Oracle8iDialect ) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.hibernate.dialect.SybaseDialect;
|
||||||
abstract public class DialectChecks {
|
abstract public class DialectChecks {
|
||||||
public static class SupportsSequences implements DialectCheck {
|
public static class SupportsSequences implements DialectCheck {
|
||||||
public boolean isMatch(Dialect dialect) {
|
public boolean isMatch(Dialect dialect) {
|
||||||
return dialect.supportsSequences();
|
return dialect.getSequenceSupport().supportsSequences();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
abstract public class DialectFeatureChecks {
|
abstract public class DialectFeatureChecks {
|
||||||
public static class SupportsSequences implements DialectFeatureCheck {
|
public static class SupportsSequences implements DialectFeatureCheck {
|
||||||
public boolean apply(Dialect dialect) {
|
public boolean apply(Dialect dialect) {
|
||||||
return dialect.supportsSequences();
|
return dialect.getSequenceSupport().supportsSequences();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue