From 29182f22d2aaa714fb1516949187d3e72e4fd242 Mon Sep 17 00:00:00 2001 From: loy Date: Mon, 16 Jul 2018 16:28:48 +0800 Subject: [PATCH] =?UTF-8?q?CORE-110=20=E8=B0=83=E6=95=B4hibernate=E6=BA=90?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=8D=95=E7=8B=AC=E9=92=88?= =?UTF-8?q?=E5=AF=B9session=E8=AE=BE=E7=BD=AE=E7=9A=84batchSize=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/jdbc/batch/internal/BatchBuilderImpl.java | 9 ++++++--- .../org/hibernate/internal/AbstractSessionImpl.java | 11 +++++++++++ .../hibernate/resource/jdbc/spi/JdbcSessionOwner.java | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/batch/internal/BatchBuilderImpl.java b/fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/batch/internal/BatchBuilderImpl.java index f8714c0b9..44ad721ae 100644 --- a/fine-hibernate/src/com/fr/third/org/hibernate/engine/jdbc/batch/internal/BatchBuilderImpl.java +++ b/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 public Batch buildBatch(BatchKey key, JdbcCoordinator jdbcCoordinator) { - LOG.tracef( "Building batch [size=%s]", size ); - return size > 1 - ? new BatchingBatch( key, jdbcCoordinator, size ) + int batchSize = jdbcCoordinator.getJdbcSessionOwner().getJdbcBatchSize() > 1 + ? jdbcCoordinator.getJdbcSessionOwner().getJdbcBatchSize() + : size; + LOG.tracef( "Building batch [size=%s]", batchSize ); + return batchSize > 1 + ? new BatchingBatch( key, jdbcCoordinator, batchSize ) : new NonBatchingBatch( key, jdbcCoordinator ); } diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java b/fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java index 50101c261..c55ccaddf 100755 --- a/fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java +++ b/fine-hibernate/src/com/fr/third/org/hibernate/internal/AbstractSessionImpl.java @@ -71,6 +71,7 @@ public abstract class AbstractSessionImpl protected transient SessionFactoryImpl factory; private final String tenantIdentifier; private boolean closed; + private int jdbcBatchSize; protected transient Transaction currentHibernateTransaction; protected transient WrapperOptionsImpl wrapperOptions; @@ -609,4 +610,14 @@ public abstract class AbstractSessionImpl return wrapperOptions; } + + @Override + public int getJdbcBatchSize() { + return jdbcBatchSize; + } + + @Override + public void setJdbcBatchSize(int jdbcBatchSize) { + this.jdbcBatchSize = jdbcBatchSize; + } } diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/resource/jdbc/spi/JdbcSessionOwner.java b/fine-hibernate/src/com/fr/third/org/hibernate/resource/jdbc/spi/JdbcSessionOwner.java index b8fa0acd9..0a45b7592 100644 --- a/fine-hibernate/src/com/fr/third/org/hibernate/resource/jdbc/spi/JdbcSessionOwner.java +++ b/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 flushBeforeTransactionCompletion(); + + public int getJdbcBatchSize(); + + public void setJdbcBatchSize(int jdbcBatchSize); }