slight simplification in IncrementGenerator
This commit is contained in:
parent
6e38830cbe
commit
72e0f2968a
|
@ -28,7 +28,7 @@ import static org.hibernate.id.IdentifierGeneratorHelper.getIntegralDataTypeHold
|
|||
import static org.hibernate.id.PersistentIdentifierGenerator.CATALOG;
|
||||
import static org.hibernate.id.PersistentIdentifierGenerator.PK;
|
||||
import static org.hibernate.id.PersistentIdentifierGenerator.SCHEMA;
|
||||
import static org.hibernate.internal.util.StringHelper.split;
|
||||
import static org.hibernate.internal.util.StringHelper.splitAtCommas;
|
||||
import static org.hibernate.internal.util.config.ConfigurationHelper.getString;
|
||||
|
||||
/**
|
||||
|
@ -85,25 +85,16 @@ public class IncrementGenerator implements IdentifierGenerator {
|
|||
public void configure(GeneratorCreationContext creationContext, Properties parameters) throws MappingException {
|
||||
returnClass = creationContext.getType().getReturnedClass();
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = creationContext.getServiceRegistry().requireService( JdbcEnvironment.class );
|
||||
final JdbcEnvironment jdbcEnvironment = creationContext.getDatabase().getJdbcEnvironment();
|
||||
final IdentifierHelper identifierHelper = jdbcEnvironment.getIdentifierHelper();
|
||||
|
||||
column = parameters.getProperty( COLUMN );
|
||||
if ( column == null ) {
|
||||
column = parameters.getProperty( PK );
|
||||
}
|
||||
column = identifierHelper.normalizeQuoting( identifierHelper.toIdentifier( column ) )
|
||||
column = identifierHelper.normalizeQuoting( identifierHelper.toIdentifier( getString( COLUMN, PK, parameters ) ) )
|
||||
.render( jdbcEnvironment.getDialect() );
|
||||
|
||||
final Identifier catalog = identifierHelper.toIdentifier( getString( CATALOG, parameters ) );
|
||||
final Identifier schema = identifierHelper.toIdentifier( getString( SCHEMA, parameters ) );
|
||||
|
||||
String tableList = parameters.getProperty( TABLES );
|
||||
if ( tableList == null ) {
|
||||
tableList = parameters.getProperty( PersistentIdentifierGenerator.TABLES );
|
||||
}
|
||||
physicalTableNames = new ArrayList<>();
|
||||
for ( String tableName : split( ", ", tableList ) ) {
|
||||
for ( String tableName : splitAtCommas( getString( TABLES, PersistentIdentifierGenerator.TABLES, parameters ) ) ) {
|
||||
physicalTableNames.add( new QualifiedTableName( catalog, schema, identifierHelper.toIdentifier( tableName ) ) );
|
||||
}
|
||||
}
|
||||
|
@ -144,9 +135,9 @@ public class IncrementGenerator implements IdentifierGenerator {
|
|||
LOG.debugf( "Fetching initial value: %s", sql );
|
||||
}
|
||||
try {
|
||||
PreparedStatement st = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
|
||||
final PreparedStatement st = session.getJdbcCoordinator().getStatementPreparer().prepareStatement( sql );
|
||||
try {
|
||||
ResultSet rs = session.getJdbcCoordinator().getResultSetReturn().extract( st, sql );
|
||||
final ResultSet rs = session.getJdbcCoordinator().getResultSetReturn().extract( st, sql );
|
||||
try {
|
||||
if ( rs.next() ) {
|
||||
previousValueHolder.initialize( rs, 0L ).increment();
|
||||
|
|
Loading…
Reference in New Issue