diff --git a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java index 7d45d89187..5091a751af 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/loading/internal/CollectionLoadContext.java @@ -352,11 +352,13 @@ public class CollectionLoadContext { final CacheKey cacheKey = session.generateCacheKey( lce.getKey(), persister.getKeyType(), persister.getRole() ); boolean isPutFromLoad = true; - for (Serializable id : entry.getState()) { - EntityPersister entityPersister = ((QueryableCollection) persister).getElementPersister(); - if ( session.getPersistenceContext().wasInsertedDuringTransaction( entityPersister, id ) ) { - isPutFromLoad = false; - break; + if ( persister.getElementType().isAssociationType() ) { + for ( Serializable id : entry.getState() ) { + EntityPersister entityPersister = ( (QueryableCollection) persister ).getElementPersister(); + if ( session.getPersistenceContext().wasInsertedDuringTransaction( entityPersister, id ) ) { + isPutFromLoad = false; + break; + } } }