Browse Source

CORE-110 调整hibernate源码,新增单独针对session设置的batchSize属性

10.0
loy 6 years ago
parent
commit
29182f22d2
  1. 9
      fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/batch/internal/BatchBuilderImpl.java
  2. 11
      fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java
  3. 4
      fine-hibernate/src/com/fr/third/org/hibernate/resource/jdbc/spi/JdbcSessionOwner.java

9
fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/batch/internal/BatchBuilderImpl.java

@ -61,9 +61,12 @@ public class BatchBuilderImpl implements BatchBuilder, Configurable, Manageable,
@Override @Override
public Batch buildBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) { public Batch buildBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) {
LOG.tracef( "Building batch [size=%s]", size ); int batchSize = jdbcCoordinator.getJdbcSessionOwner().getJdbcBatchSize() > 1
return size > 1 ? jdbcCoordinator.getJdbcSessionOwner().getJdbcBatchSize()
? new BatchingBatch( key, jdbcCoordinator, size ) : size;
LOG.tracef( "Building batch [size=%s]", batchSize );
return batchSize > 1
? new BatchingBatch( key, jdbcCoordinator, batchSize )
: new NonBatchingBatch( key, jdbcCoordinator ); : new NonBatchingBatch( key, jdbcCoordinator );
} }

11
fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java

@ -71,6 +71,7 @@ public abstract class AbstractSessionImpl
protected transient SessionFactoryImpl factory; protected transient SessionFactoryImpl factory;
private final String tenantIdentifier; private final String tenantIdentifier;
private boolean closed; private boolean closed;
private int jdbcBatchSize;
protected transient Transaction currentHibernateTransaction; protected transient Transaction currentHibernateTransaction;
protected transient WrapperOptionsImpl wrapperOptions; protected transient WrapperOptionsImpl wrapperOptions;
@ -609,4 +610,14 @@ public abstract class AbstractSessionImpl
return wrapperOptions; return wrapperOptions;
} }
@Override
public int getJdbcBatchSize() {
return jdbcBatchSize;
}
@Override
public void setJdbcBatchSize(int jdbcBatchSize) {
this.jdbcBatchSize = jdbcBatchSize;
}
} }

4
fine-hibernate/src/com/fr/third/org/hibernate/resource/jdbc/spi/JdbcSessionOwner.java

@ -43,4 +43,8 @@ public interface JdbcSessionOwner {
public void afterTransactionCompletion(boolean successful, boolean delayed); public void afterTransactionCompletion(boolean successful, boolean delayed);
public void flushBeforeTransactionCompletion(); public void flushBeforeTransactionCompletion();
public int getJdbcBatchSize();
public void setJdbcBatchSize(int jdbcBatchSize);
} }

Loading…
Cancel
Save