remove use of deprecated accessors of SessionFactoryImplementor

This commit is contained in:
Gavin King 2022-01-23 10:46:40 +01:00
parent be831f9690
commit 4b26cb5876
38 changed files with 102 additions and 111 deletions

View File

@ -172,7 +172,7 @@ public class ThreadLocalSessionContext extends AbstractCurrentSessionContext {
* @return The connection release mode for any built sessions.
*/
protected ConnectionReleaseMode getConnectionReleaseMode() {
return factory().getSettings().getConnectionReleaseMode();
return factory().getSessionFactoryOptions().getPhysicalConnectionHandlingMode().getReleaseMode();
}
protected Session wrap(Session session) {

View File

@ -1518,7 +1518,8 @@ public abstract class Dialect implements ConversionContext {
return target;
}
catch (SQLException e ) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge BLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper()
.convert( e, "unable to merge BLOB data" );
}
}
else {
@ -1538,7 +1539,7 @@ public abstract class Dialect implements ConversionContext {
return target;
}
catch (SQLException e ) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge CLOB data" );
}
}
else {
@ -1558,7 +1559,7 @@ public abstract class Dialect implements ConversionContext {
return target;
}
catch (SQLException e ) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge NCLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge NCLOB data" );
}
}
else {
@ -1585,7 +1586,7 @@ public abstract class Dialect implements ConversionContext {
: lobCreator.createBlob( original.getBinaryStream(), original.length() );
}
catch (SQLException e) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge BLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge BLOB data" );
}
}
@ -1601,7 +1602,7 @@ public abstract class Dialect implements ConversionContext {
: lobCreator.createClob( original.getCharacterStream(), original.length() );
}
catch (SQLException e) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge CLOB data" );
}
}
@ -1617,7 +1618,7 @@ public abstract class Dialect implements ConversionContext {
: lobCreator.createNClob( original.getCharacterStream(), original.length() );
}
catch (SQLException e) {
throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge NCLOB data" );
throw session.getFactory().getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge NCLOB data" );
}
}
};

View File

@ -121,7 +121,7 @@ public class PessimisticReadUpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getDialect() );
final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -119,7 +119,7 @@ public class PessimisticWriteUpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getDialect() );
final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -123,7 +123,7 @@ public class UpdateLockingStrategy implements LockingStrategy {
protected String generateLockString() {
final SessionFactoryImplementor factory = lockable.getFactory();
final Update update = new Update( factory.getDialect() );
final Update update = new Update( factory.getJdbcServices().getDialect() );
update.setTableName( lockable.getRootTableName() );
update.addPrimaryKeyColumns( lockable.getRootTableIdentifierColumnNames() );
update.setVersionColumnName( lockable.getVersionColumnName() );

View File

@ -214,7 +214,7 @@ public final class ForeignKeys {
// case we definitely need to nullify
if ( object == self ) {
return isEarlyInsert
|| ( isDelete && session.getFactory().getDialect().hasSelfReferentialForeignKeyBug() );
|| ( isDelete && session.getFactory().getJdbcServices().getDialect().hasSelfReferentialForeignKeyBug() );
}
// See if the entity is already bound to this session, if not look at the

View File

@ -154,7 +154,7 @@ public abstract class AbstractBatchImpl implements Batch {
protected void releaseStatements() {
final LinkedHashMap<String, PreparedStatement> statements = getStatements();
final ResourceRegistry resourceRegistry = jdbcCoordinator.getResourceRegistry();
final ResourceRegistry resourceRegistry = jdbcCoordinator.getLogicalConnection().getResourceRegistry();
for ( PreparedStatement statement : statements.values() ) {
clearBatch( statement );
resourceRegistry.release( statement );

View File

@ -45,7 +45,7 @@ public class NonBatchingBatch extends AbstractBatchImpl {
final PreparedStatement statement = entry.getValue();
final int rowCount = jdbcCoordinator.getResultSetReturn().executeUpdate( statement );
getKey().getExpectation().verifyOutcome( rowCount, statement, 0, statementSQL );
jdbcCoordinator.getResourceRegistry().release( statement );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement );
jdbcCoordinator.afterStatementExecution();
}
catch ( SQLException e ) {

View File

@ -274,11 +274,11 @@ public class JdbcCoordinatorImpl implements JdbcCoordinator {
}
private void releaseResources() {
getResourceRegistry().releaseResources();
getLogicalConnection().getResourceRegistry().releaseResources();
}
private boolean hasRegisteredResources() {
return getResourceRegistry().hasRegisteredResources();
return getLogicalConnection().getResourceRegistry().hasRegisteredResources();
}
private ConnectionReleaseMode determineConnectionReleaseMode(

View File

@ -227,7 +227,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
private void postExtract(ResultSet rs, Statement st) {
if ( rs != null ) {
jdbcCoordinator.getResourceRegistry().register( rs, st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().register( rs, st );
}
}

View File

@ -62,7 +62,7 @@ class StatementPreparerImpl implements StatementPreparer {
public Statement createStatement() {
try {
final Statement statement = connection().createStatement();
jdbcCoordinator.getResourceRegistry().register( statement, true );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().register( statement, true );
return statement;
}
catch ( SQLException e ) {
@ -190,7 +190,7 @@ class StatementPreparerImpl implements StatementPreparer {
protected abstract PreparedStatement doPrepare() throws SQLException;
public void postProcess(PreparedStatement preparedStatement) throws SQLException {
jdbcCoordinator.getResourceRegistry().register( preparedStatement, true );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().register( preparedStatement, true );
// logicalConnection().notifyObserversStatementPrepared();
}

View File

@ -12,13 +12,11 @@ import java.io.Serializable;
import java.sql.Connection;
import java.sql.Statement;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.engine.jdbc.batch.spi.Batch;
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
import org.hibernate.jdbc.WorkExecutorVisitable;
import org.hibernate.resource.jdbc.ResourceRegistry;
import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.transaction.backend.jdbc.spi.JdbcResourceTransactionAccess;
import org.hibernate.resource.transaction.spi.TransactionCoordinatorOwner;

View File

@ -202,22 +202,22 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getProperties();
}
@Override
@Override @Deprecated
public EntityPersister getEntityPersister(String entityName) throws MappingException {
return delegate.getEntityPersister( entityName );
}
@Override
@Override @Deprecated
public Map<String, EntityPersister> getEntityPersisters() {
return delegate.getEntityPersisters();
}
@Override
@Override @Deprecated
public CollectionPersister getCollectionPersister(String role) throws MappingException {
return delegate.getCollectionPersister( role );
}
@Override
@Override @Deprecated
public Map<String, CollectionPersister> getCollectionPersisters() {
return delegate.getCollectionPersisters();
}
@ -232,17 +232,17 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getSqlStringGenerationContext();
}
@Override
@Override @Deprecated
public Dialect getDialect() {
return delegate.getDialect();
return delegate.getJdbcServices().getDialect();
}
@Override
@Override @Deprecated
public String[] getImplementors(String className) throws MappingException {
return delegate.getImplementors( className );
}
@Override
@Override @Deprecated
public String getImportedClassName(String name) {
return delegate.getImportedClassName( name );
}
@ -257,22 +257,22 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.bestGuessEntityName( object );
}
@Override
@Override @Deprecated
public StatisticsImplementor getStatisticsImplementor() {
return delegate.getStatistics();
}
@Override
@Override @Deprecated
public SQLExceptionConverter getSQLExceptionConverter() {
return delegate.getSQLExceptionConverter();
}
@Override
@Override @Deprecated
public SqlExceptionHelper getSQLExceptionHelper() {
return delegate.getSQLExceptionHelper();
return delegate.getJdbcServices().getSqlExceptionHelper();
}
@Override
@Override @Deprecated
public Settings getSettings() {
return delegate.getSettings();
}
@ -282,7 +282,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.openTemporarySession();
}
@Override
@Override @Deprecated
public Set<String> getCollectionRolesByEntityParticipant(String entityName) {
return delegate.getCollectionRolesByEntityParticipant( entityName );
}
@ -327,7 +327,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getCurrentTenantIdentifierResolver();
}
@Override
@Override @Deprecated
public Iterable<EntityNameResolver> iterateEntityNameResolvers() {
return delegate.iterateEntityNameResolvers();
}
@ -337,12 +337,12 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
return delegate.getFastSessionServices();
}
@Override
@Override @Deprecated
public EntityPersister locateEntityPersister(Class<?> byClass) {
return delegate.locateEntityPersister( byClass );
}
@Override
@Override @Deprecated
public EntityPersister locateEntityPersister(String byName) {
return delegate.locateEntityPersister( byName );
}

View File

@ -240,7 +240,6 @@ public interface SessionFactoryImplementor
* @deprecated since 5.0; use {@link #getSessionFactoryOptions()} instead
*/
@Deprecated
@SuppressWarnings("deprecation")
Settings getSettings();

View File

@ -157,7 +157,7 @@ public class DefaultDeleteEventListener implements DeleteEventListener, Callback
transientEntities
);
if ( source.getFactory().getSettings().isIdentifierRollbackEnabled() ) {
if ( source.getFactory().getSessionFactoryOptions().isIdentifierRollbackEnabled() ) {
persister.resetIdentifier( entity, id, version, source );
}
}

View File

@ -163,7 +163,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
this.flushMode = options.getInitialSessionFlushMode();
this.tenantIdentifier = options.getTenantIdentifier();
if ( factory.getSettings().isMultiTenancyEnabled() && tenantIdentifier == null ) {
if ( factory.getSessionFactoryOptions().isMultiTenancyEnabled() && tenantIdentifier == null ) {
throw new HibernateException( "SessionFactory configured for multi-tenancy, but no tenant identifier specified" );
}

View File

@ -222,7 +222,7 @@ public final class FastSessionServices {
this.preferredSqlTypeCodeForBoolean = sessionFactoryOptions.getPreferredSqlTypeCodeForBoolean();
this.defaultTimeZoneStorageStrategy = sessionFactoryOptions.getDefaultTimeZoneStorageStrategy();
this.defaultJdbcBatchSize = sessionFactoryOptions.getJdbcBatchSize();
this.requiresMultiTenantConnectionProvider = sf.getSettings().isMultiTenancyEnabled();
this.requiresMultiTenantConnectionProvider = sf.getSessionFactoryOptions().isMultiTenancyEnabled();
//Some "hot" services:
this.connectionProvider = requiresMultiTenantConnectionProvider ? null : sr.getService( ConnectionProvider.class );

View File

@ -301,8 +301,8 @@ public abstract class AbstractCollectionPersister
cacheEntryStructure = UnstructuredCacheEntry.INSTANCE;
}
dialect = factory.getDialect();
sqlExceptionHelper = factory.getSQLExceptionHelper();
dialect = factory.getJdbcServices().getDialect();
sqlExceptionHelper = factory.getJdbcServices().getSqlExceptionHelper();
collectionType = collectionBootDescriptor.getCollectionType();
navigableRole = new NavigableRole( collectionBootDescriptor.getRole() );
entityName = collectionBootDescriptor.getOwnerEntityName();
@ -522,7 +522,7 @@ public abstract class AbstractCollectionPersister
identifierColumnAlias = col.getAlias( dialect );
identifierGenerator = idColl.getIdentifier().createIdentifierGenerator(
persisterCreationContext.getBootstrapContext().getIdentifierGeneratorFactory(),
factory.getDialect(),
factory.getJdbcServices().getDialect(),
null
);
identifierGenerator.initialize( creationContext.getSessionFactory().getSqlStringGenerationContext() );
@ -1435,7 +1435,7 @@ public abstract class AbstractCollectionPersister
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -1547,7 +1547,7 @@ public abstract class AbstractCollectionPersister
}
finally {
if ( !useBatch ) {
jdbcCoordinator.getResourceRegistry().release( st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( st );
jdbcCoordinator.afterStatementExecution();
}
}
@ -1668,7 +1668,7 @@ public abstract class AbstractCollectionPersister
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -1779,7 +1779,7 @@ public abstract class AbstractCollectionPersister
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -2202,11 +2202,11 @@ public abstract class AbstractCollectionPersister
return rs.next() ? rs.getInt( 1 ) - baseIndex : 0;
}
finally {
jdbcCoordinator.getResourceRegistry().release( rs, st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( rs, st );
}
}
finally {
jdbcCoordinator.getResourceRegistry().release( st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( st );
jdbcCoordinator.afterStatementExecution();
}
}
@ -2244,14 +2244,14 @@ public abstract class AbstractCollectionPersister
return rs.next();
}
finally {
jdbcCoordinator.getResourceRegistry().release( rs, st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( rs, st );
}
}
catch ( TransientObjectException e ) {
return false;
}
finally {
jdbcCoordinator.getResourceRegistry().release( st );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( st );
jdbcCoordinator.afterStatementExecution();
}
}

View File

@ -63,7 +63,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
PersisterCreationContext creationContext) throws MappingException, CacheException {
super( collectionBinding, cacheAccessStrategy, creationContext );
cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled()
&& creationContext.getSessionFactory().getDialect().supportsCascadeDelete();
&& creationContext.getSessionFactory().getJdbcServices().getDialect().supportsCascadeDelete();
keyIsNullable = collectionBinding.getKey().isNullable();
keyIsUpdateable = collectionBinding.getKey().isUpdateable();
}
@ -276,7 +276,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -389,7 +389,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -461,7 +461,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
}
finally {
if ( !useBatch ) {
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
session.getJdbcCoordinator().afterStatementExecution();
}
}
@ -470,7 +470,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
return count;
}
catch (SQLException sqle) {
throw getFactory().getSQLExceptionHelper().convert(
throw getFactory().getJdbcServices().getSqlExceptionHelper().convert(
sqle,
"could not update collection rows: " +
MessageHelper.collectionInfoString( this, collection, id, session ),

View File

@ -6096,7 +6096,7 @@ public abstract class AbstractEntityPersister
assert selectableIterator.hasNext();
final Selectable selectable = selectableIterator.next();
assert attrColumnExpression.equals( selectable.getText( sessionFactory.getDialect() ) );
assert attrColumnExpression.equals( selectable.getText(sessionFactory.getJdbcServices().getDialect()) );
customReadExpr = selectable.getTemplate( dialect, sessionFactory.getQueryEngine().getSqmFunctionRegistry() );
customWriteExpr = selectable.getCustomWriteExpression();

View File

@ -175,8 +175,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
}
else {
final Column column = (Column) selectable;
explicitDiscriminatorColumnName = column.getQuotedName( factory.getDialect() );
discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() );
explicitDiscriminatorColumnName = column.getQuotedName(factory.getJdbcServices().getDialect());
discriminatorAlias = column.getAlias(factory.getJdbcServices().getDialect(), persistentClass.getRootTable() );
}
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
if ( persistentClass.isDiscriminatorValueNull() ) {

View File

@ -459,7 +459,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
protected String generateSubquery(PersistentClass model, Mapping mapping) {
Dialect dialect = getFactory().getJdbcServices().getDialect();
Settings settings = getFactory().getSettings();
SqlStringGenerationContext sqlStringGenerationContext = getFactory().getSqlStringGenerationContext();
if ( !model.hasSubclasses() ) {

View File

@ -69,7 +69,7 @@ public class StatisticsInitiator implements SessionFactoryServiceInitiator<Stati
if ( configValue == null ) {
statisticsFactory = null; //We'll use the default
}
else if ( StatisticsFactory.class.isInstance( configValue ) ) {
else if ( configValue instanceof StatisticsFactory ) {
statisticsFactory = (StatisticsFactory) configValue;
}
else {
@ -83,7 +83,7 @@ public class StatisticsInitiator implements SessionFactoryServiceInitiator<Stati
}
catch (Exception e) {
throw new HibernateException(
"Unable to instantiate specified StatisticsFactory implementation [" + configValue.toString() + "]",
"Unable to instantiate specified StatisticsFactory implementation [" + configValue + "]",
e
);
}
@ -96,7 +96,7 @@ public class StatisticsInitiator implements SessionFactoryServiceInitiator<Stati
else {
statistics = statisticsFactory.buildStatistics( sessionFactory );
}
final boolean enabled = sessionFactory.getSettings().isStatisticsEnabled();
final boolean enabled = sessionFactory.getSessionFactoryOptions().isStatisticsEnabled();
statistics.setStatisticsEnabled( enabled );
LOG.debugf( "Statistics initialized [enabled=%s]", enabled );
return statistics;

View File

@ -130,10 +130,10 @@ public class BasicOperationsTest {
String columnNamePattern = generateFinalNamePattern( meta, columnName );
ResultSet columnInfo = meta.getColumns( null, null, tableNamePattern, columnNamePattern );
s.getJdbcCoordinator().getResourceRegistry().register( columnInfo, columnInfo.getStatement() );
s.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().register( columnInfo, columnInfo.getStatement() );
assertTrue( columnInfo.next() );
int dataType = columnInfo.getInt( "DATA_TYPE" );
s.getJdbcCoordinator().getResourceRegistry().release( columnInfo, columnInfo.getStatement() );
s.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( columnInfo, columnInfo.getStatement() );
assertEquals(
JdbcTypeNameMapper.getTypeName( expectedJdbcTypeCode ),
JdbcTypeNameMapper.getTypeName( dataType ),

View File

@ -94,8 +94,7 @@ public class QueryAndSQLTest {
@Test
public void testNativeQueryWithFormulaAttribute(SessionFactoryScope scope) {
final String dateFunctionRendered = scope.getSessionFactory()
.getDialect()
final String dateFunctionRendered = scope.getSessionFactory().getJdbcServices().getDialect()
.currentDate();
String sql = String.format(
@ -129,8 +128,7 @@ public class QueryAndSQLTest {
public void testNativeQueryWithFormulaAttributeWithoutAlias(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
String sql = "select TABLE_NAME , " + scope.getSessionFactory()
.getDialect()
String sql = "select TABLE_NAME , " + scope.getSessionFactory().getJdbcServices().getDialect()
.currentDate() + " as daysOld from ALL_TABLES where TABLE_NAME = 'AUDIT_ACTIONS' ";
session.createNativeQuery( sql ).addEntity( "t", AllTables.class ).list();
}

View File

@ -48,26 +48,26 @@ public class BatchTest extends BaseCoreFunctionalTestCase {
final int N = 5000; //26 secs with batch flush, 26 without
//final int N = 100000; //53 secs with batch flush, OOME without
//final int N = 250000; //137 secs with batch flush, OOME without
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdate( N, batchSize );
System.out.println( System.currentTimeMillis() - start );
}
@Test
public void testBatchInsertUpdateSizeEqJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdate( 50, batchSize );
}
@Test
public void testBatchInsertUpdateSizeLtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdate( 50, batchSize - 1 );
}
@Test
public void testBatchInsertUpdateSizeGtJdbcBatchSize() {
int batchSize = sessionFactory().getSettings().getJdbcBatchSize();
int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
doBatchInsertUpdate( 50, batchSize + 1 );
}

View File

@ -159,7 +159,7 @@ public class SQLExceptionConversionTest extends BaseCoreFunctionalTestCase {
private void releaseStatement(Session session, PreparedStatement ps) {
if ( ps != null ) {
try {
( (SessionImplementor) session ).getJdbcCoordinator().getResourceRegistry().release( ps );
((SessionImplementor) session).getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( ps );
}
catch ( Throwable ignore ) {
// ignore...

View File

@ -9,10 +9,8 @@ package org.hibernate.orm.test.id;
import java.util.Properties;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataBuildingContext;
@ -82,7 +80,7 @@ public class SequenceStyleGeneratorBehavesLikeSequeceHiloGeneratorWitZeroIncreme
sessionFactory = (SessionFactoryImplementor) metadata.buildSessionFactory();
generator.initialize( sessionFactory.getSqlStringGenerationContext() );
sequenceValueExtractor = new SequenceValueExtractor( sessionFactory.getDialect(), TEST_SEQUENCE );
sequenceValueExtractor = new SequenceValueExtractor(sessionFactory.getJdbcServices().getDialect(), TEST_SEQUENCE );
}
@AfterEach

View File

@ -154,7 +154,7 @@ public class GeneralWorkTest extends BaseCoreFunctionalTestCase {
return;
}
try {
s.getJdbcCoordinator().getResourceRegistry().release( statement );
s.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( statement );
}
catch (Exception e) {
// ignore
@ -166,7 +166,7 @@ public class GeneralWorkTest extends BaseCoreFunctionalTestCase {
return;
}
try {
s.getJdbcCoordinator().getResourceRegistry().release( resultSet, statement );
s.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( resultSet, statement );
}
catch (Exception e) {
// ignore

View File

@ -131,7 +131,7 @@ public class AggressiveReleaseTest extends BaseSessionFactoryFunctionalTest {
ps.setLong( 1, 1 );
ps.setString( 2, "name" );
jdbcCoord.getResultSetReturn().execute( ps );
assertTrue( jdbcCoord.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoord.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertEquals( 1, connectionProvider.getAcquiredConnections().size() );
assertEquals( 0, connectionProvider.getReleasedConnections().size() );
resourceRegistry.release( ps );

View File

@ -106,6 +106,6 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase {
}
private ResourceRegistry getResourceRegistry(JdbcCoordinator jdbcCoord) {
return jdbcCoord.getResourceRegistry();
return jdbcCoord.getLogicalConnection().getResourceRegistry();
}
}

View File

@ -66,10 +66,10 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
// ignore if the DB doesn't support "if exists" and the table doesn't exist
}
jdbcCoordinator.getResultSetReturn().execute( statement, "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() );
jdbcCoordinator.getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() ); // after_transaction specified
// ok, now we can get down to it...
@ -94,12 +94,12 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.execute();
assertEquals( 1, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.release();
@ -124,10 +124,10 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
catch ( Exception e ) {
// ignore if the DB doesn't support "if exists" and the table doesn't exist
} jdbcCoordinator.getResultSetReturn().execute( statement, "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() );
jdbcCoordinator.getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() ); // after_transaction specified
// ok, now we can get down to it...
@ -152,7 +152,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 0, batchObserver.getImplicitExecutionCount() );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
PreparedStatement insert2 = insertBatch.getBatchStatement( insertSql, false );
assertSame( insert, insert2 );
@ -164,12 +164,12 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.execute();
assertEquals( 1, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.release();
@ -195,10 +195,10 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
catch ( Exception e ) {
// ignore if the DB doesn't support "if exists" and the table doesn't exist
} jdbcCoordinator.getResultSetReturn().execute( statement, "create table SANDBOX_JDBC_TST ( ID integer, NAME varchar(100) )" );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() );
jdbcCoordinator.getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
jdbcCoordinator.getLogicalConnection().getResourceRegistry().release( statement );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
assertTrue( logicalConnection.isPhysicallyConnected() ); // after_transaction specified
// ok, now we can get down to it...
@ -223,7 +223,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 0, batchObserver.getImplicitExecutionCount() );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
PreparedStatement insert2 = insertBatch.getBatchStatement( insertSql, false );
assertSame( insert, insert2 );
@ -235,7 +235,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 0, batchObserver.getImplicitExecutionCount() );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
PreparedStatement insert3 = insertBatch.getBatchStatement( insertSql, false );
assertSame( insert, insert3 );
@ -247,12 +247,12 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey
insertBatch.addToBatch();
assertEquals( 0, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertTrue( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertTrue( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.execute();
assertEquals( 1, batchObserver.getExplicitExecutionCount() );
assertEquals( 1, batchObserver.getImplicitExecutionCount() );
assertFalse( jdbcCoordinator.getResourceRegistry().hasRegisteredResources() );
assertFalse( jdbcCoordinator.getLogicalConnection().getResourceRegistry().hasRegisteredResources() );
insertBatch.release();

View File

@ -66,7 +66,7 @@ public class MixedTest {
Long did = doc.getId();
Long d2id = doc2.getId();
if ( !scope.getSessionFactory().getDialect().supportsExpectedLobUsagePattern() ) {
if ( !scope.getSessionFactory().getJdbcServices().getDialect().supportsExpectedLobUsagePattern() ) {
SkipLog.reportSkip( "database/driver does not support expected LOB usage pattern", "LOB support" );
return;
}

View File

@ -51,7 +51,7 @@ public class RowIdTest2 {
st,
"create table Point (\"x\" number(19,2) not null, \"y\" number(19,2) not null, description varchar2(255) )"
);
session.getJdbcCoordinator().getResourceRegistry().release( st );
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
}
)
);

View File

@ -60,8 +60,7 @@ public class SessionWithSharedConnectionTest {
//the list should have registered and then released a JDBC resource
assertFalse(
((SessionImplementor) secondSession)
.getJdbcCoordinator()
.getResourceRegistry()
.getJdbcCoordinator().getLogicalConnection().getResourceRegistry()
.hasRegisteredResources()
);

View File

@ -23,7 +23,6 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Assert;
import org.junit.Test;
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
import static org.junit.Assert.assertEquals;
/**
@ -129,8 +128,8 @@ public class AutoDiscoveryTest extends BaseCoreFunctionalTestCase {
Assert.assertFalse( "bad dialect.getColumnAliasExtractor impl", column1Alias.equals( column2Alias ) );
}
finally {
sessionImplementor.getJdbcCoordinator().getResourceRegistry().release( rs, ps );
sessionImplementor.getJdbcCoordinator().getResourceRegistry().release( ps );
sessionImplementor.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( rs, ps );
sessionImplementor.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( ps );
}
}
}

View File

@ -69,7 +69,7 @@ public class TimePropertyTest {
final String queryString;
if ( SQLServerDialect.class.isAssignableFrom( scope.getSessionFactory().getDialect().getClass() ) ) {
if ( SQLServerDialect.class.isAssignableFrom( scope.getSessionFactory().getJdbcServices().getDialect().getClass() ) ) {
queryString = "from TimePropertyTest$Entity where tAsDate = cast ( ?1 as time )";
}
else {

View File

@ -65,7 +65,7 @@ public class ResultTransformerTest {
ScrollableResults sr = q.scroll();
// HANA supports only ResultSet.TYPE_FORWARD_ONLY and
// does not support java.sql.ResultSet.first()
if ( scope.getSessionFactory().getDialect() instanceof AbstractHANADialect ) {
if ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof AbstractHANADialect ) {
sr.next();
}
else {