);
//JDBC and connection settings:
//Interrogate JDBC metadata
ExtractedDatabaseMetaData meta = jdbcServices.getExtractedMetaDataSupport();
settings.setDataDefinitionImplicitCommit( meta.doesDataDefinitionCauseTransactionCommit() );
settings.setDataDefinitionInTransactionSupported( meta.supportsDataDefinitionInTransaction() );
//use dialect default properties
final Properties properties = new Properties();
properties.putAll( jdbcServices.getDialect().getDefaultProperties() );
properties.putAll( props );
// Transaction settings:
settings.setJtaPlatform( serviceRegistry.getService( JtaPlatform.class ) );
MultiTableBulkIdStrategy multiTableBulkIdStrategy = strategySelector.resolveStrategy(
MultiTableBulkIdStrategy.class,
properties.getProperty( AvailableSettings.HQL_BULK_ID_STRATEGY )
);
if ( multiTableBulkIdStrategy == null ) {
multiTableBulkIdStrategy = jdbcServices.getDialect().supportsTemporaryTables()
? TemporaryTableBulkIdStrategy.INSTANCE
: new PersistentTableBulkIdStrategy();
}
settings.setMultiTableBulkIdStrategy( multiTableBulkIdStrategy );
boolean flushBeforeCompletion = ConfigurationHelper.getBoolean(AvailableSettings.FLUSH_BEFORE_COMPLETION, properties);
if ( debugEnabled ) {
LOG.debugf( "Automatic flush during beforeCompletion(): %s", enabledDisabled(flushBeforeCompletion) );
}
settings.setFlushBeforeCompletionEnabled(flushBeforeCompletion);
boolean autoCloseSession = ConfigurationHelper.getBoolean(AvailableSettings.AUTO_CLOSE_SESSION, properties);
if ( debugEnabled ) {
LOG.debugf( "Automatic session close at end of transaction: %s", enabledDisabled(autoCloseSession) );
}
settings.setAutoCloseSessionEnabled(autoCloseSession);
//JDBC and connection settings:
int batchSize = ConfigurationHelper.getInt(AvailableSettings.STATEMENT_BATCH_SIZE, properties, 0);
if ( !meta.supportsBatchUpdates() ) {
batchSize = 0;
}
if ( batchSize > 0 && debugEnabled ) {
LOG.debugf( "JDBC batch size: %s", batchSize );
}
settings.setJdbcBatchSize(batchSize);
boolean jdbcBatchVersionedData = ConfigurationHelper.getBoolean(AvailableSettings.BATCH_VERSIONED_DATA, properties, false);
if ( batchSize > 0 && debugEnabled ) {
LOG.debugf( "JDBC batch updates for versioned data: %s", enabledDisabled(jdbcBatchVersionedData) );
}
settings.setJdbcBatchVersionedData(jdbcBatchVersionedData);
boolean useScrollableResultSets = ConfigurationHelper.getBoolean(
AvailableSettings.USE_SCROLLABLE_RESULTSET,
properties,
meta.supportsScrollableResults()
);
if ( debugEnabled ) {
LOG.debugf( "Scrollable result sets: %s", enabledDisabled(useScrollableResultSets) );
}
settings.setScrollableResultSetsEnabled(useScrollableResultSets);
boolean wrapResultSets = ConfigurationHelper.getBoolean(AvailableSettings.WRAP_RESULT_SETS, properties, false);
if ( debugEnabled ) {
LOG.debugf( "Wrap result sets: %s", enabledDisabled(wrapResultSets) );
}
settings.setWrapResultSetsEnabled(wrapResultSets);
boolean useGetGeneratedKeys = ConfigurationHelper.getBoolean(AvailableSettings.USE_GET_GENERATED_KEYS, properties, meta.supportsGetGeneratedKeys());
if ( debugEnabled ) {
LOG.debugf( "JDBC3 getGeneratedKeys(): %s", enabledDisabled(useGetGeneratedKeys) );
}
settings.setGetGeneratedKeysEnabled(useGetGeneratedKeys);