From ea388c8c82692b348df28e9cd9e1422f55a6fc12 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Wed, 18 Jun 2014 10:02:37 -0700 Subject: [PATCH] HHH-9231 : Avoid updating collection 2LC if contains entity added in tx (cherry picked from commit 4851ab01dfc2c58c19bf08a68854593923907716) --- .../loading/internal/CollectionLoadContext.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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; + } } }