diff --git a/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java index 64042ba74b..d0da90b827 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java @@ -694,6 +694,15 @@ public interface SessionFactoryBuilder { */ SessionFactoryBuilder applySqlFunction(String registrationName, SqmFunctionDescriptor functionDescriptor); + /** + * Should collections be included in the default fetch group when bytecode enhancement is used? + * + * @param enabled {@code true} collections should be included + * + * @return {@code this}, for method chaining + */ + SessionFactoryBuilder applyCollectionsInDefaultFetchGroup(boolean enabled); + SessionFactoryBuilder allowOutOfTransactionUpdateOperations(boolean allow); /** diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java index 375112466c..4a1e2cfe6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java @@ -387,6 +387,12 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement return this; } + @Override + public SessionFactoryBuilder applyCollectionsInDefaultFetchGroup(boolean enabled) { + this.optionsBuilder.enableCollectionInDefaultFetchGroup( enabled ); + return this; + } + @Override public SessionFactoryBuilder allowOutOfTransactionUpdateOperations(boolean allow) { this.optionsBuilder.allowOutOfTransactionUpdateOperations( allow ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java index 2b47206926..96f5b39103 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java @@ -110,7 +110,6 @@ import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED; import static org.hibernate.cfg.AvailableSettings.JTA_TRACK_BY_THREAD; import static org.hibernate.cfg.AvailableSettings.LOG_SESSION_METRICS; import static org.hibernate.cfg.AvailableSettings.MAX_FETCH_DEPTH; -import static org.hibernate.cfg.AvailableSettings.MULTI_TENANT_CONNECTION_PROVIDER; import static org.hibernate.cfg.AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER; import static org.hibernate.cfg.AvailableSettings.NATIVE_EXCEPTION_HANDLING_51_COMPLIANCE; import static org.hibernate.cfg.AvailableSettings.OMIT_JOIN_OF_SUPERCLASS_TABLES; @@ -146,9 +145,9 @@ import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; * In-flight state of {@link SessionFactoryOptions} * during {@link org.hibernate.boot.SessionFactoryBuilder} processing. * - * The intention is that SessionFactoryBuilder internally creates and populates - * this builder, which is then used to construct the SessionFactoryOptions - * as part of building the SessionFactory ({@link org.hibernate.boot.SessionFactoryBuilder#build}) + * The intention is that {@code SessionFactoryBuilder} internally creates and populates + * this builder, which is then used to construct the {@code SessionFactoryOptions} + * as part of building the {@code SessionFactory} ({@link org.hibernate.boot.SessionFactoryBuilder#build}) * * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java index f577e2a39f..2739b42f81 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java @@ -368,6 +368,12 @@ public abstract class AbstractDelegatingSessionFactoryBuilder persistentCollection = (PersistentCollection) association; if ( !persistentCollection.wasInitialized() ) { 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 eb2d2e1043..aa783bc7e6 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 @@ -216,7 +216,6 @@ import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.Template; import org.hibernate.sql.Update; import org.hibernate.sql.ast.Clause; -import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SimpleFromClauseAccessImpl; import org.hibernate.sql.ast.spi.SqlAliasBase; @@ -4252,10 +4251,9 @@ public abstract class AbstractEntityPersister final EntityKey entityKey = proxyInterceptor.getEntityKey(); final Object identifier = entityKey.getIdentifier(); - - LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource)session, false ); Object loaded = null; - if ( canReadFromCache ) { + if ( canReadFromCache && session instanceof EventSource ) { + LoadEvent loadEvent = new LoadEvent( identifier, entity, (EventSource) session, false ); loaded = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( loadEvent, this, entityKey ); } if ( loaded == null ) {