10
10
import org .hibernate .Session ;
11
11
import org .hibernate .collection .spi .PersistentCollection ;
12
12
import org .hibernate .engine .spi .CollectionKey ;
13
- import org .hibernate .engine .spi .EntityEntry ;
14
13
import org .hibernate .engine .spi .EntityKey ;
15
14
import org .hibernate .engine .spi .SharedSessionContractImplementor ;
16
15
import org .hibernate .metamodel .mapping .EntityMappingType ;
@@ -78,7 +77,7 @@ public static void lockCollectionTable(
78
77
final String keyTableName = keyDescriptor .getKeyTable ();
79
78
80
79
if ( SQL_EXEC_LOGGER .isDebugEnabled () ) {
81
- SQL_EXEC_LOGGER .debugf ( "Collection locking for collection table `%s` - %s" , keyTableName , attributeMapping .getRootPathName () );
80
+ SQL_EXEC_LOGGER .collectionLockingForCollectionTable ( keyTableName , attributeMapping .getRootPathName () );
82
81
}
83
82
84
83
final var querySpec = new QuerySpec ( true );
@@ -153,7 +152,7 @@ public static void lockCollectionTable(
153
152
* @param lockTimeout A lock timeout to apply, if one.
154
153
* @param ownerDetailsMap Details for each owner, whose collection-table rows should be locked.
155
154
*/
156
- public static void lockCollectionTable (
155
+ public static void lockCollectionTable (
157
156
PluralAttributeMapping attributeMapping ,
158
157
LockMode lockMode ,
159
158
Timeout lockTimeout ,
@@ -163,7 +162,7 @@ public static void lockCollectionTable(
163
162
final String keyTableName = keyDescriptor .getKeyTable ();
164
163
165
164
if ( SQL_EXEC_LOGGER .isDebugEnabled () ) {
166
- SQL_EXEC_LOGGER .debugf ( "Follow-on locking for collection table `%s` - %s" , keyTableName , attributeMapping .getRootPathName () );
165
+ SQL_EXEC_LOGGER .followOnLockingForCollectionTable ( keyTableName , attributeMapping .getRootPathName () );
167
166
}
168
167
169
168
final var querySpec = new QuerySpec ( true );
@@ -323,7 +322,7 @@ public static void lockCollectionTable(
323
322
final String keyTableName = keyDescriptor .getKeyTable ();
324
323
325
324
if ( SQL_EXEC_LOGGER .isDebugEnabled () ) {
326
- SQL_EXEC_LOGGER .debugf ( "Follow-on locking for collection table `%s` - %s" , keyTableName , attributeMapping .getRootPathName () );
325
+ SQL_EXEC_LOGGER .followOnLockingForCollectionTable ( keyTableName , attributeMapping .getRootPathName () );
327
326
}
328
327
329
328
final var querySpec = new QuerySpec ( true );
@@ -465,22 +464,28 @@ private static void performLocking(
465
464
*/
466
465
public static void logLoadedValues (LoadedValuesCollector collector ) {
467
466
if ( SQL_EXEC_LOGGER .isDebugEnabled () ) {
468
- SQL_EXEC_LOGGER .debug ( "Follow-on locking collected loaded values..." );
469
-
470
- SQL_EXEC_LOGGER .debug ( " Loaded root entities:" );
467
+ var summary = new StringBuilder ();
468
+ summary .append ( " Loaded root entities:\n " );
471
469
collector .getCollectedRootEntities ().forEach ( (reg ) -> {
472
- SQL_EXEC_LOGGER .debugf ( " - %s#%s" , reg .entityDescriptor ().getEntityName (), reg .entityKey ().getIdentifier () );
470
+ summary .append ( String .format ( " - %s#%s\n " ,
471
+ reg .entityDescriptor ().getEntityName (),
472
+ reg .entityKey ().getIdentifier () ) );
473
473
} );
474
474
475
- SQL_EXEC_LOGGER . debug ( " Loaded non-root entities:" );
475
+ summary . append ( " Loaded non-root entities:\n " );
476
476
collector .getCollectedNonRootEntities ().forEach ( (reg ) -> {
477
- SQL_EXEC_LOGGER .debugf ( " - %s#%s" , reg .entityDescriptor ().getEntityName (), reg .entityKey ().getIdentifier () );
477
+ summary .append ( String .format ( " - %s#%s\n " ,
478
+ reg .entityDescriptor ().getEntityName ()
479
+ , reg .entityKey ().getIdentifier () ) );
478
480
} );
479
481
480
- SQL_EXEC_LOGGER . debug ( " Loaded collections:" );
482
+ summary . append ( " Loaded collections:\n " );
481
483
collector .getCollectedCollections ().forEach ( (reg ) -> {
482
- SQL_EXEC_LOGGER .debugf ( " - %s#%s" , reg .collectionDescriptor ().getRootPathName (), reg .collectionKey ().getKey () );
484
+ summary .append ( String .format ( " - %s#%s\n " ,
485
+ reg .collectionDescriptor ().getRootPathName (),
486
+ reg .collectionKey ().getKey () ) );
483
487
} );
488
+ SQL_EXEC_LOGGER .followOnLockingCollectedLoadedValues ( summary .toString () );
484
489
}
485
490
}
486
491
@@ -547,8 +552,8 @@ public static Map<Object, EntityDetails> resolveEntityKeys(List<EntityKey> entit
547
552
final var persistenceContext = executionContext .getSession ().getPersistenceContext ();
548
553
entityKeys .forEach ( (entityKey ) -> {
549
554
final Object instance = persistenceContext .getEntity ( entityKey );
550
- final EntityEntry entry = persistenceContext .getEntry ( instance );
551
- map .put ( entityKey .getIdentifierValue (), new EntityDetails ( entityKey , entry , instance ) );
555
+ final var entityEntry = persistenceContext .getEntry ( instance );
556
+ map .put ( entityKey .getIdentifierValue (), new EntityDetails ( entityKey , entityEntry , instance ) );
552
557
} );
553
558
return map ;
554
559
}
0 commit comments