Skip to content

Commit ede60d8

Browse files
committed
[hibernate#2139] Explain why we set the default batch size to 0
1 parent 2acd894 commit ede60d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/impl/ReactiveStatelessSessionImpl.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ private ReactiveStatelessSessionImpl(
150150
PersistenceContext persistenceContext) {
151151
super( factory, options );
152152
this.persistenceContext = persistenceContext;
153-
// Setting batch size to 0 because `StatelessSession` does not consider
154-
// the value of `hibernate.jdbc.batch_size`
153+
// StatelessSession should not allow JDBC batching, because that would change
154+
// its "immediate synchronous execution" model into something more like transactional
155+
// write-behind and be confusing. For this reason, the default batch size is always set to 0.
156+
// When a user calls the CRUD operations for batching, we set the batch size to the same number of
157+
// objects to process, therefore, there is no write-behind behavior.
155158
reactiveConnection = new BatchingConnection( connection, 0 );
156159
batchingHelperSession = this;
157160
influencers = new LoadQueryInfluencers( factory );

0 commit comments

Comments
 (0)