Skip to content

Commit a38f45f

Browse files
gavinkingDavideD
authored andcommitted
add new methods from H6.3 to control batch/subselect fetching
1 parent 1b32686 commit a38f45f

File tree

5 files changed

+149
-1
lines changed

5 files changed

+149
-1
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,53 @@ default Session setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
13361336
*/
13371337
Filter getEnabledFilter(String filterName);
13381338

1339+
/**
1340+
* Get the maximum batch size for batch fetching associations by
1341+
* id in this session.
1342+
*
1343+
* @since 2.1
1344+
*/
1345+
int getFetchBatchSize();
1346+
1347+
/**
1348+
* Set the maximum batch size for batch fetching associations by
1349+
* id in this session.
1350+
* Override the default controlled by the configuration property
1351+
* {@code hibernate.default_batch_fetch_size}.
1352+
* <p>
1353+
* <ul>
1354+
* <li>If {@code batchSize>1}, then batch fetching is enabled.
1355+
* <li>If {@code batchSize<0}, the batch size is inherited from
1356+
* the factory-level setting.
1357+
* <li>Otherwise, batch fetching is disabled.
1358+
* </ul>
1359+
*
1360+
* @param batchSize the maximum batch size for batch fetching
1361+
*
1362+
* @since 2.1
1363+
*/
1364+
Session setFetchBatchSize(int batchSize);
1365+
1366+
/**
1367+
* Determine if subselect fetching is enabled in this session.
1368+
*
1369+
* @return {@code true} if subselect fetching is enabled
1370+
*
1371+
* @since 2.1
1372+
*/
1373+
boolean isSubselectFetchingEnabled();
1374+
1375+
/**
1376+
* Enable or disable subselect fetching in this session.
1377+
* Override the default controlled by the configuration property
1378+
* {@code hibernate.use_subselect_fetch}.
1379+
*
1380+
* @param enabled {@code true} to enable subselect fetching
1381+
*
1382+
* @since 2.1
1383+
*/
1384+
Session setSubselectFetchingEnabled(boolean enabled);
1385+
13391386
/**
13401387
* Performs the given work within the scope of a database transaction,
13411388
* automatically flushing the session. The transaction will be rolled

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinySessionImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,28 @@ public Filter getEnabledFilter(String filterName) {
437437
return delegate.getEnabledFilter( filterName );
438438
}
439439

440+
@Override
441+
public int getFetchBatchSize() {
442+
return delegate.getFetchBatchSize();
443+
}
444+
445+
@Override
446+
public Mutiny.Session setFetchBatchSize(int batchSize) {
447+
delegate.setFetchBatchSize( batchSize );
448+
return this;
449+
}
450+
451+
@Override
452+
public boolean isSubselectFetchingEnabled() {
453+
return delegate.isSubselectFetchingEnabled();
454+
}
455+
456+
@Override
457+
public Mutiny.Session setSubselectFetchingEnabled(boolean enabled) {
458+
delegate.setSubselectFetchingEnabled( enabled );
459+
return this;
460+
}
461+
440462
@Override
441463
public <T> Uni<T> withTransaction(Function<Mutiny.Transaction, Uni<T>> work) {
442464
return currentTransaction == null

hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveSession.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ public interface ReactiveSession extends ReactiveQueryProducer, ReactiveSharedSe
128128
void enableFetchProfile(String name) throws UnknownProfileException;
129129
void disableFetchProfile(String name) throws UnknownProfileException;
130130

131+
int getFetchBatchSize();
132+
void setFetchBatchSize(int batchSize);
133+
boolean isSubselectFetchingEnabled();
134+
void setSubselectFetchingEnabled(boolean enabled);
135+
131136
void clear();
132137

133138
boolean isDirty();

hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
*/
66
package org.hibernate.reactive.stage;
77

8-
import jakarta.persistence.*;
8+
import jakarta.persistence.CacheRetrieveMode;
9+
import jakarta.persistence.CacheStoreMode;
10+
import jakarta.persistence.EntityGraph;
11+
import jakarta.persistence.FlushModeType;
12+
import jakarta.persistence.LockModeType;
13+
import jakarta.persistence.Parameter;
914
import jakarta.persistence.criteria.CriteriaBuilder;
1015
import jakarta.persistence.criteria.CriteriaDelete;
1116
import jakarta.persistence.criteria.CriteriaQuery;
@@ -1333,6 +1338,53 @@ default Session setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
13331338
*/
13341339
Integer getBatchSize();
13351340

1341+
/**
1342+
* Get the maximum batch size for batch fetching associations by
1343+
* id in this session.
1344+
*
1345+
* @since 2.1
1346+
*/
1347+
int getFetchBatchSize();
1348+
1349+
/**
1350+
* Set the maximum batch size for batch fetching associations by
1351+
* id in this session.
1352+
* Override the default controlled by the configuration property
1353+
* {@code hibernate.default_batch_fetch_size}.
1354+
* <p>
1355+
* <ul>
1356+
* <li>If {@code batchSize>1}, then batch fetching is enabled.
1357+
* <li>If {@code batchSize<0}, the batch size is inherited from
1358+
* the factory-level setting.
1359+
* <li>Otherwise, batch fetching is disabled.
1360+
* </ul>
1361+
*
1362+
* @param batchSize the maximum batch size for batch fetching
1363+
*
1364+
* @since 2.1
1365+
*/
1366+
Stage.Session setFetchBatchSize(int batchSize);
1367+
1368+
/**
1369+
* Determine if subselect fetching is enabled in this session.
1370+
*
1371+
* @return {@code true} if subselect fetching is enabled
1372+
*
1373+
* @since 2.1
1374+
*/
1375+
boolean isSubselectFetchingEnabled();
1376+
1377+
/**
1378+
* Enable or disable subselect fetching in this session.
1379+
* Override the default controlled by the configuration property
1380+
* {@code hibernate.use_subselect_fetch}.
1381+
*
1382+
* @param enabled {@code true} to enable subselect fetching
1383+
*
1384+
* @since 2.1
1385+
*/
1386+
Stage.Session setSubselectFetchingEnabled(boolean enabled);
1387+
13361388
/**
13371389
* Enable the named filter for this session.
13381390
*

hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageSessionImpl.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,28 @@ public Filter getEnabledFilter(String filterName) {
362362
return delegate.getEnabledFilter(filterName);
363363
}
364364

365+
@Override
366+
public int getFetchBatchSize() {
367+
return delegate.getFetchBatchSize();
368+
}
369+
370+
@Override
371+
public Stage.Session setFetchBatchSize(int batchSize) {
372+
delegate.setFetchBatchSize( batchSize );
373+
return this;
374+
}
375+
376+
@Override
377+
public boolean isSubselectFetchingEnabled() {
378+
return delegate.isSubselectFetchingEnabled();
379+
}
380+
381+
@Override
382+
public Stage.Session setSubselectFetchingEnabled(boolean enabled) {
383+
delegate.setSubselectFetchingEnabled( enabled );
384+
return this;
385+
}
386+
365387
@Override
366388
public <T> CompletionStage<T> withTransaction(Function<Stage.Transaction, CompletionStage<T>> work) {
367389
return currentTransaction==null ? new Transaction<T>().execute(work) : work.apply(currentTransaction);

0 commit comments

Comments
 (0)