diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index 0a06e294e8..ca962c4493 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -309,7 +309,9 @@ public abstract class AbstractCollectionPersister hasOrphanDelete = collectionBootDescriptor.hasOrphanDelete(); - batchSize = collectionBootDescriptor.getBatchSize(); + batchSize = collectionBootDescriptor.getBatchSize() < 0 + ? factory.getSessionFactoryOptions().getDefaultBatchFetchSize() + : collectionBootDescriptor.getBatchSize(); isVersioned = collectionBootDescriptor.isOptimisticLocked(); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 9b465c7cb3..e6cb55a4cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -506,7 +506,9 @@ public abstract class AbstractEntityPersister final Dialect dialect = creationContext.getDialect(); - batchSize = persistentClass.getBatchSize(); + batchSize = persistentClass.getBatchSize() < 0 + ? factory.getSessionFactoryOptions().getDefaultBatchFetchSize() + : persistentClass.getBatchSize(); hasSubselectLoadableCollections = persistentClass.hasSubselectLoadableCollections(); hasPartitionedSelectionMapping = persistentClass.hasPartitionedSelectionMapping(); hasCollectionNotReferencingPK = persistentClass.hasCollectionNotReferencingPK();