Skip to content

Commit a277548

Browse files
committed
minor aesthetic cleanups in batch loader logging
1 parent 273959c commit a277548

7 files changed

+44
-44
lines changed

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractCollectionBatchLoader.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.hasSingleId;
2525
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.trimIdBatch;
2626
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
27+
import static org.hibernate.pretty.MessageHelper.collectionInfoString;
2728

2829
/**
2930
* @author Steve Ebersole
@@ -80,8 +81,8 @@ public int getKeyJdbcCount() {
8081
@Override
8182
public PersistentCollection<?> load(Object key, SharedSessionContractImplementor session) {
8283
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
83-
MULTI_KEY_LOAD_LOGGER.tracef( "Batch fetching collection: %s.%s",
84-
getLoadable().getNavigableRole().getFullPath(), key );
84+
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching collection: "
85+
+ collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ) );
8586
}
8687

8788
final Object[] keys = resolveKeysToInitialize( key, session );
@@ -106,8 +107,8 @@ protected void finishInitializingKey(Object key, SharedSessionContractImplemento
106107
}
107108

108109
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
109-
MULTI_KEY_LOAD_LOGGER.tracef( "Finishing initializing batch-fetched collection: %s.%s",
110-
attributeMapping.getNavigableRole().getFullPath(), key );
110+
MULTI_KEY_LOAD_LOGGER.trace( "Finishing initializing batch-fetched collection: "
111+
+ collectionInfoString( attributeMapping.getNavigableRole().getFullPath(), key ) );
111112
}
112113

113114
final PersistenceContext persistenceContext = session.getPersistenceContext();

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractEntityBatchLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.hasSingleId;
1717
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
18+
import static org.hibernate.pretty.MessageHelper.infoString;
1819

1920
public abstract class AbstractEntityBatchLoader<T>
2021
extends SingleIdEntityLoaderSupport<T>
@@ -45,7 +46,8 @@ public final T load(
4546
Boolean readOnly,
4647
SharedSessionContractImplementor session) {
4748
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
48-
MULTI_KEY_LOAD_LOGGER.tracef( "Batch fetching entity `%s#%s`", getLoadable().getEntityName(), id );
49+
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching entity: "
50+
+ infoString( getLoadable().getEntityName(), id ) );
4951
}
5052

5153
final Object[] ids = resolveIdsToInitialize( id, session );
@@ -59,7 +61,8 @@ public T load(
5961
LockOptions lockOptions,
6062
SharedSessionContractImplementor session) {
6163
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
62-
MULTI_KEY_LOAD_LOGGER.tracef( "Batch fetching entity `%s#%s`", getLoadable().getEntityName(), id );
64+
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching entity: "
65+
+ infoString( getLoadable().getEntityName(), id ) );
6366
}
6467

6568
final Object[] ids = resolveIdsToInitialize( id, session );

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionBatchLoaderArrayParam.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.hasSingleId;
3737
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.trimIdBatch;
3838
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
39+
import static org.hibernate.pretty.MessageHelper.collectionInfoString;
3940

4041
/**
4142
* {@link CollectionBatchLoader} using a SQL {@code ARRAY} parameter to pass the key values.
@@ -60,7 +61,7 @@ public CollectionBatchLoaderArrayParam(
6061

6162
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
6263
MULTI_KEY_LOAD_LOGGER.tracef(
63-
"Using ARRAY batch fetching strategy for collection `%s` : %s",
64+
"Batch fetching enabled for collection '%s' using ARRAY strategy with batch size %s",
6465
attributeMapping.getNavigableRole().getFullPath(),
6566
domainBatchSize
6667
);
@@ -116,10 +117,8 @@ private PersistentCollection<?> loadEmbeddable(
116117
SharedSessionContractImplementor session,
117118
ForeignKeyDescriptor keyDescriptor) {
118119
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
119-
MULTI_KEY_LOAD_LOGGER.tracef(
120-
"Batch fetching collection: %s.%s",
121-
getLoadable().getNavigableRole().getFullPath(), keyBeingLoaded
122-
);
120+
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching collection: "
121+
+ collectionInfoString( getLoadable().getNavigableRole().getFullPath(), keyBeingLoaded ) );
123122
}
124123

125124
final int length = getDomainBatchSize();
@@ -168,12 +167,9 @@ private PersistentCollection<?> loadEmbeddable(
168167
@Override
169168
void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContractImplementor session) {
170169
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
171-
MULTI_KEY_LOAD_LOGGER.tracef(
172-
"Collection keys to batch-fetch initialize (`%s#%s`) %s",
173-
getLoadable().getNavigableRole().getFullPath(),
174-
key,
175-
keysToInitialize
176-
);
170+
MULTI_KEY_LOAD_LOGGER.tracef( "Collection keys to initialize via batch fetching (%s) %s",
171+
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
172+
keysToInitialize );
177173
}
178174

179175
assert jdbcSelectOperation != null;

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CollectionBatchLoaderInPredicate.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.countIds;
2525
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
26+
import static org.hibernate.pretty.MessageHelper.collectionInfoString;
2627

2728
/**
2829
* {@link CollectionBatchLoader} for batch fetching using a SQL {@code IN} predicate.
@@ -50,9 +51,9 @@ public CollectionBatchLoaderInPredicate(
5051
.getDialect()
5152
.getBatchLoadSizingStrategy()
5253
.determineOptimalBatchLoadSize( keyColumnCount, domainBatchSize, false );
53-
if ( MULTI_KEY_LOAD_LOGGER.isDebugEnabled() ) {
54+
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
5455
MULTI_KEY_LOAD_LOGGER.tracef(
55-
"Using IN-predicate batch fetching strategy for collection `%s` : %s (%s)",
56+
"Batch fetching enabled for collection '%s' using IN-predicate with batch size %s (%s)",
5657
attributeMapping.getNavigableRole().getFullPath(),
5758
sqlBatchSize,
5859
domainBatchSize
@@ -91,9 +92,8 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
9192
final boolean loggerDebugEnabled = MULTI_KEY_LOAD_LOGGER.isDebugEnabled();
9293
if ( loggerDebugEnabled ) {
9394
MULTI_KEY_LOAD_LOGGER.tracef(
94-
"Collection keys to batch-fetch initialize (`%s#%s`) %s",
95-
getLoadable().getNavigableRole().getFullPath(),
96-
key,
95+
"Collection keys to initialize via batch fetching (%s) %s",
96+
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
9797
keysToInitialize
9898
);
9999
}
@@ -127,9 +127,8 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
127127
(startIndex) -> {
128128
if ( loggerDebugEnabled ) {
129129
MULTI_KEY_LOAD_LOGGER.tracef(
130-
"Processing collection batch-fetch chunk (`%s#%s`) %s - %s",
131-
getLoadable().getNavigableRole().getFullPath(),
132-
key,
130+
"Processing collection batch-fetch chunk (%s) %s - %s",
131+
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
133132
startIndex,
134133
startIndex + (sqlBatchSize-1)
135134
);
@@ -138,9 +137,8 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
138137
(startIndex, nonNullElementCount) -> {
139138
if ( loggerDebugEnabled ) {
140139
MULTI_KEY_LOAD_LOGGER.tracef(
141-
"Finishing collection batch-fetch chunk (`%s#%s`) %s - %s (%s)",
142-
getLoadable().getNavigableRole().getFullPath(),
143-
key,
140+
"Finishing collection batch-fetch chunk (%s) %s - %s (%s)",
141+
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
144142
startIndex,
145143
startIndex + (sqlBatchSize-1),
146144
nonNullElementCount

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityBatchLoaderArrayParam.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import static org.hibernate.loader.ast.internal.LoaderHelper.loadByArrayParameter;
3030
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.trimIdBatch;
3131
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
32+
import static org.hibernate.pretty.MessageHelper.infoString;
3233

3334
/**
3435
* {@link SingleIdEntityLoaderSupport} implementation based on using a single
@@ -69,7 +70,7 @@ public EntityBatchLoaderArrayParam(
6970

7071
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
7172
MULTI_KEY_LOAD_LOGGER.tracef(
72-
"Batch fetching enabled for `%s` (entity) using ARRAY strategy : %s",
73+
"Batch fetching enabled for entity '%s' using ARRAY strategy with batch size %s",
7374
entityDescriptor.getEntityName(),
7475
domainBatchSize
7576
);
@@ -127,8 +128,9 @@ protected void initializeEntities(
127128
Boolean readOnly,
128129
SharedSessionContractImplementor session) {
129130
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
130-
MULTI_KEY_LOAD_LOGGER.tracef( "Ids to batch-fetch initialize (`%s#%s`) %s",
131-
getLoadable().getEntityName(), id, Arrays.toString(idsToInitialize) );
131+
MULTI_KEY_LOAD_LOGGER.tracef( "Entity ids to initialize via batch fetching (%s) %s",
132+
infoString( getLoadable().getEntityName(), id),
133+
Arrays.toString( idsToInitialize ) );
132134
}
133135

134136
removeBatchLoadableEntityKeys( idsToInitialize, session );

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/EntityBatchLoaderInPredicate.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.hibernate.sql.exec.spi.JdbcParametersList;
2525

2626
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
27+
import static org.hibernate.pretty.MessageHelper.infoString;
2728

2829
/**
2930
* An {@link EntityBatchLoader} using one or more SQL queries, which each initialize up
@@ -63,10 +64,10 @@ public EntityBatchLoaderInPredicate(
6364

6465
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
6566
MULTI_KEY_LOAD_LOGGER.tracef(
66-
"Batch fetching `%s` entity using padded IN-list: %s (%s)",
67+
"Batch fetching enabled for entity '%s' using IN-predicate with batch size %s (%s)",
6768
entityDescriptor.getEntityName(),
68-
domainBatchSize,
69-
sqlBatchSize
69+
sqlBatchSize,
70+
domainBatchSize
7071
);
7172
}
7273

@@ -122,8 +123,9 @@ protected void initializeEntities(
122123
Boolean readOnly,
123124
SharedSessionContractImplementor session) {
124125
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
125-
MULTI_KEY_LOAD_LOGGER.tracef( "Ids to batch-fetch initialize (`%s#%s`) %s",
126-
getLoadable().getEntityName(), pkValue, Arrays.toString(idsToInitialize) );
126+
MULTI_KEY_LOAD_LOGGER.tracef( "Entity ids to initialize via batch fetching (%s) %s",
127+
infoString( getLoadable().getEntityName(), pkValue ),
128+
Arrays.toString(idsToInitialize) );
127129
}
128130

129131
final BatchFetchQueue batchFetchQueue = session.getPersistenceContextInternal().getBatchFetchQueue();
@@ -158,9 +160,8 @@ protected void initializeEntities(
158160
(startIndex) -> {
159161
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
160162
MULTI_KEY_LOAD_LOGGER.tracef(
161-
"Processing entity batch-fetch chunk (`%s#%s`) %s - %s",
162-
getLoadable().getEntityName(),
163-
pkValue,
163+
"Processing entity batch-fetch chunk (%s) %s - %s",
164+
infoString( getLoadable().getEntityName(), pkValue ),
164165
startIndex,
165166
startIndex + ( sqlBatchSize - 1 )
166167
);

hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderInPredicate.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import static java.util.Collections.singletonList;
3030
import static org.hibernate.engine.spi.SubselectFetch.createRegistrationHandler;
3131
import static org.hibernate.loader.ast.internal.LoaderSelectBuilder.createSelect;
32-
import static org.hibernate.loader.ast.internal.MultiKeyLoadLogging.MULTI_KEY_LOAD_LOGGER;
3332

3433
/**
3534
* Standard implementation of {@link org.hibernate.loader.ast.spi.MultiIdEntityLoader}
@@ -96,10 +95,10 @@ private List<T> performRegularMultiLoad(
9695
MultiIdLoadOptions loadOptions,
9796
SharedSessionContractImplementor session,
9897
int numberOfIdsInBatch) {
99-
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
100-
MULTI_KEY_LOAD_LOGGER.tracef( "#loadEntitiesById(`%s`, `%s`, ..)",
101-
getLoadable().getEntityName(), numberOfIdsInBatch );
102-
}
98+
// if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
99+
// MULTI_KEY_LOAD_LOGGER.tracef( "#loadEntitiesById(`%s`, `%s`, ..)",
100+
// getLoadable().getEntityName(), numberOfIdsInBatch );
101+
// }
103102

104103
final JdbcParametersList.Builder jdbcParametersBuilder =
105104
JdbcParametersList.newBuilder( numberOfIdsInBatch * idJdbcTypeCount );

0 commit comments

Comments
 (0)