|
4 | 4 | */ |
5 | 5 | package org.hibernate.engine.internal; |
6 | 6 |
|
7 | | -import java.io.IOException; |
8 | | -import java.io.InvalidObjectException; |
9 | | -import java.io.ObjectInputStream; |
10 | | -import java.io.ObjectOutputStream; |
11 | | -import java.io.Serializable; |
12 | | -import java.lang.invoke.MethodHandles; |
13 | | -import java.util.ArrayList; |
14 | | -import java.util.Collection; |
15 | | -import java.util.Collections; |
16 | | -import java.util.HashMap; |
17 | | -import java.util.HashSet; |
18 | | -import java.util.IdentityHashMap; |
19 | | -import java.util.Iterator; |
20 | | -import java.util.Map; |
21 | | -import java.util.Map.Entry; |
22 | | -import java.util.NoSuchElementException; |
23 | | -import java.util.function.BiConsumer; |
24 | | -import java.util.function.Consumer; |
25 | | -import java.util.function.Supplier; |
26 | | - |
| 7 | +import org.checkerframework.checker.nullness.qual.Nullable; |
27 | 8 | import org.hibernate.AssertionFailure; |
28 | 9 | import org.hibernate.Hibernate; |
29 | 10 | import org.hibernate.HibernateException; |
|
67 | 48 | import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; |
68 | 49 | import org.hibernate.sql.results.spi.LoadContexts; |
69 | 50 | import org.hibernate.type.CollectionType; |
70 | | - |
71 | 51 | import org.jboss.logging.Logger; |
72 | 52 |
|
73 | | -import org.checkerframework.checker.nullness.qual.Nullable; |
| 53 | +import java.io.IOException; |
| 54 | +import java.io.InvalidObjectException; |
| 55 | +import java.io.ObjectInputStream; |
| 56 | +import java.io.ObjectOutputStream; |
| 57 | +import java.io.Serializable; |
| 58 | +import java.lang.invoke.MethodHandles; |
| 59 | +import java.util.ArrayList; |
| 60 | +import java.util.Collection; |
| 61 | +import java.util.Collections; |
| 62 | +import java.util.HashMap; |
| 63 | +import java.util.HashSet; |
| 64 | +import java.util.IdentityHashMap; |
| 65 | +import java.util.Iterator; |
| 66 | +import java.util.Map; |
| 67 | +import java.util.Map.Entry; |
| 68 | +import java.util.NoSuchElementException; |
| 69 | +import java.util.function.BiConsumer; |
| 70 | +import java.util.function.Consumer; |
| 71 | +import java.util.function.Supplier; |
74 | 72 |
|
75 | 73 | import static org.hibernate.engine.internal.ManagedTypeHelper.asHibernateProxy; |
76 | 74 | import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity; |
@@ -330,10 +328,7 @@ public Object[] getDatabaseSnapshot(Object id, EntityPersister persister) throws |
330 | 328 | } |
331 | 329 | else { |
332 | 330 | final Object[] snapshot = persister.getDatabaseSnapshot( id, session ); |
333 | | - if ( entitySnapshotsByKey == null ) { |
334 | | - entitySnapshotsByKey = CollectionHelper.mapOfSize( INIT_COLL_SIZE ); |
335 | | - } |
336 | | - entitySnapshotsByKey.put( key, snapshot == null ? NO_ROW : snapshot ); |
| 331 | + getOrInitializeEntitySnapshotsByKey().put( key, snapshot == null ? NO_ROW : snapshot ); |
337 | 332 | return snapshot; |
338 | 333 | } |
339 | 334 | } |
@@ -1187,7 +1182,8 @@ public void initializeNonLazyCollections() throws HibernateException { |
1187 | 1182 | initializeNonLazyCollections( PersistentCollection::forceInitialization ); |
1188 | 1183 | } |
1189 | 1184 |
|
1190 | | - protected void initializeNonLazyCollections(Consumer<PersistentCollection<?>> initializeAction ) { |
| 1185 | + @Override |
| 1186 | + public void initializeNonLazyCollections(Consumer<PersistentCollection<?>> initializeAction) { |
1191 | 1187 | if ( loadCounter == 0 ) { |
1192 | 1188 | LOG.trace( "Initializing non-lazy collections" ); |
1193 | 1189 |
|
@@ -1314,6 +1310,19 @@ public Map<EntityKey,Object> getEntitiesByKey() { |
1314 | 1310 | return result; |
1315 | 1311 | } |
1316 | 1312 |
|
| 1313 | + @Override |
| 1314 | + public Map<EntityKey, Object> getEntitySnapshotsByKey() { |
| 1315 | + return entitySnapshotsByKey; |
| 1316 | + } |
| 1317 | + |
| 1318 | + @Override |
| 1319 | + public Map<EntityKey, Object> getOrInitializeEntitySnapshotsByKey() { |
| 1320 | + if ( entitySnapshotsByKey == null ) { |
| 1321 | + entitySnapshotsByKey = CollectionHelper.mapOfSize( INIT_COLL_SIZE ); |
| 1322 | + } |
| 1323 | + return entitySnapshotsByKey; |
| 1324 | + } |
| 1325 | + |
1317 | 1326 | @Override |
1318 | 1327 | public Map<EntityKey, EntityHolder> getEntityHoldersByKey() { |
1319 | 1328 | //noinspection unchecked,rawtypes |
|
0 commit comments