Skip to content

Commit 69bc8a1

Browse files
committed
introduce new infoString methods for batch loaders
1 parent 77c8cc9 commit 69bc8a1

11 files changed

+36
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public int getKeyJdbcCount() {
8282
public PersistentCollection<?> load(Object key, SharedSessionContractImplementor session) {
8383
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
8484
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching collection: "
85-
+ collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ) );
85+
+ collectionInfoString( getLoadable(), key ) );
8686
}
8787

8888
final Object[] keys = resolveKeysToInitialize( key, session );
@@ -108,7 +108,7 @@ protected void finishInitializingKey(Object key, SharedSessionContractImplemento
108108

109109
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
110110
MULTI_KEY_LOAD_LOGGER.trace( "Finishing initializing batch-fetched collection: "
111-
+ collectionInfoString( attributeMapping.getNavigableRole().getFullPath(), key ) );
111+
+ collectionInfoString( attributeMapping, key ) );
112112
}
113113

114114
final PersistenceContext persistenceContext = session.getPersistenceContext();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public final T load(
4747
SharedSessionContractImplementor session) {
4848
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
4949
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching entity: "
50-
+ infoString( getLoadable().getEntityName(), id ) );
50+
+ infoString( getLoadable(), id ) );
5151
}
5252

5353
final Object[] ids = resolveIdsToInitialize( id, session );
@@ -62,7 +62,7 @@ public T load(
6262
SharedSessionContractImplementor session) {
6363
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
6464
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching entity: "
65-
+ infoString( getLoadable().getEntityName(), id ) );
65+
+ infoString( getLoadable(), id ) );
6666
}
6767

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private List<T> performUnorderedMultiLoad(
9292
assert !loadOptions.isOrderReturnEnabled();
9393
assert ids != null;
9494
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
95-
MULTI_KEY_LOAD_LOGGER.tracef( "Unordered MultiLoad starting: "
95+
MULTI_KEY_LOAD_LOGGER.tracef( "Unordered batch load starting: "
9696
+ getLoadable().getEntityName() );
9797
}
9898
return unorderedMultiLoad( ids, loadOptions, session );
@@ -105,7 +105,7 @@ private List<T> performOrderedMultiLoad(
105105
assert loadOptions.isOrderReturnEnabled();
106106
assert ids != null;
107107
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
108-
MULTI_KEY_LOAD_LOGGER.tracef( "Ordered MultiLoad starting: "
108+
MULTI_KEY_LOAD_LOGGER.tracef( "Ordered batch load starting: "
109109
+ getLoadable().getEntityName() );
110110
}
111111
return orderedMultiLoad( ids, loadOptions, session );

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private <K> List<E> performUnorderedMultiLoad(
5252
MultiNaturalIdLoadOptions loadOptions,
5353
SharedSessionContractImplementor session) {
5454
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
55-
MULTI_KEY_LOAD_LOGGER.tracef( "Unordered MultiLoad starting: "
55+
MULTI_KEY_LOAD_LOGGER.tracef( "Unordered batch load starting: "
5656
+ getEntityDescriptor().getEntityName() );
5757
}
5858
return unorderedMultiLoad( naturalIds, loadOptions, session );

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package org.hibernate.loader.ast.internal;
66

7-
import java.lang.reflect.Array;
87

98
import org.hibernate.LockOptions;
109
import org.hibernate.collection.spi.PersistentCollection;
@@ -33,6 +32,7 @@
3332
import org.hibernate.sql.results.internal.RowTransformerStandardImpl;
3433
import org.hibernate.sql.results.spi.ListResultsConsumer;
3534

35+
import static java.lang.reflect.Array.newInstance;
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;
@@ -118,19 +118,19 @@ private PersistentCollection<?> loadEmbeddable(
118118
ForeignKeyDescriptor keyDescriptor) {
119119
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
120120
MULTI_KEY_LOAD_LOGGER.trace( "Batch fetching collection: "
121-
+ collectionInfoString( getLoadable().getNavigableRole().getFullPath(), keyBeingLoaded ) );
121+
+ collectionInfoString( getLoadable(), keyBeingLoaded ) );
122122
}
123123

124124
final int length = getDomainBatchSize();
125-
final Object[] keysToInitialize = (Object[]) Array.newInstance(
125+
final Object[] keysToInitialize = (Object[]) newInstance(
126126
jdbcParameter.getExpressionType()
127127
.getSingleJdbcMapping()
128128
.getJdbcJavaType()
129129
.getJavaTypeClass()
130130
.getComponentType(),
131131
length
132132
);
133-
final Object[] embeddedKeys = (Object[]) Array.newInstance( keyDomainType, length );
133+
final Object[] embeddedKeys = (Object[]) newInstance( keyDomainType, length );
134134
session.getPersistenceContextInternal().getBatchFetchQueue()
135135
.collectBatchLoadableCollectionKeys(
136136
length,
@@ -168,7 +168,7 @@ private PersistentCollection<?> loadEmbeddable(
168168
void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContractImplementor session) {
169169
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
170170
MULTI_KEY_LOAD_LOGGER.tracef( "Collection keys to initialize via batch fetching (%s) %s",
171-
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
171+
collectionInfoString( getLoadable(), key ),
172172
keysToInitialize );
173173
}
174174

@@ -214,7 +214,7 @@ Object[] resolveKeysToInitialize(Object keyBeingLoaded, SharedSessionContractImp
214214
if( keyDescriptor.isEmbedded()){
215215
assert keyDescriptor.getJdbcTypeCount() == 1;
216216
final int length = getDomainBatchSize();
217-
final Object[] keysToInitialize = (Object[]) Array.newInstance( keyDescriptor.getSingleJdbcMapping().getJdbcJavaType().getJavaTypeClass(), length );
217+
final Object[] keysToInitialize = (Object[]) newInstance( keyDescriptor.getSingleJdbcMapping().getJdbcJavaType().getJavaTypeClass(), length );
218218
session.getPersistenceContextInternal().getBatchFetchQueue()
219219
.collectBatchLoadableCollectionKeys(
220220
length,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
9393
if ( loggerDebugEnabled ) {
9494
MULTI_KEY_LOAD_LOGGER.tracef(
9595
"Collection keys to initialize via batch fetching (%s) %s",
96-
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
96+
collectionInfoString( getLoadable(), key ),
9797
keysToInitialize
9898
);
9999
}
@@ -128,7 +128,7 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
128128
if ( loggerDebugEnabled ) {
129129
MULTI_KEY_LOAD_LOGGER.tracef(
130130
"Processing collection batch-fetch chunk (%s) %s - %s",
131-
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
131+
collectionInfoString( getLoadable(), key ),
132132
startIndex,
133133
startIndex + (sqlBatchSize-1)
134134
);
@@ -138,7 +138,7 @@ void initializeKeys(Object key, Object[] keysToInitialize, SharedSessionContract
138138
if ( loggerDebugEnabled ) {
139139
MULTI_KEY_LOAD_LOGGER.tracef(
140140
"Finishing collection batch-fetch chunk (%s) %s - %s (%s)",
141-
collectionInfoString( getLoadable().getNavigableRole().getFullPath(), key ),
141+
collectionInfoString( getLoadable(), key ),
142142
startIndex,
143143
startIndex + (sqlBatchSize-1),
144144
nonNullElementCount

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343
import org.hibernate.type.BasicType;
4444
import org.hibernate.type.StandardBasicTypes;
4545

46-
import org.jboss.logging.Logger;
46+
import static org.hibernate.loader.LoaderLogging.LOADER_LOGGER;
47+
import static org.hibernate.pretty.MessageHelper.infoString;
4748

4849
/**
4950
* @author Steve Ebersole
5051
*/
5152
class DatabaseSnapshotExecutor {
52-
private static final Logger log = Logger.getLogger( DatabaseSnapshotExecutor.class );
5353

5454
private final EntityMappingType entityDescriptor;
5555

@@ -154,8 +154,9 @@ class DatabaseSnapshotExecutor {
154154
}
155155

156156
Object[] loadDatabaseSnapshot(Object id, SharedSessionContractImplementor session) {
157-
if ( log.isTraceEnabled() ) {
158-
log.tracef( "Getting current persistent state for `%s#%s`", entityDescriptor.getEntityName(), id );
157+
if ( LOADER_LOGGER.isTraceEnabled() ) {
158+
LOADER_LOGGER.trace( "Retrieving snapshot of current persistent state for "
159+
+ infoString( entityDescriptor, id ) );
159160
}
160161

161162
final JdbcParameterBindings jdbcParameterBindings = new JdbcParameterBindingsImpl(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected void initializeEntities(
129129
SharedSessionContractImplementor session) {
130130
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
131131
MULTI_KEY_LOAD_LOGGER.tracef( "Entity ids to initialize via batch fetching (%s) %s",
132-
infoString( getLoadable().getEntityName(), id),
132+
infoString( getLoadable(), id),
133133
Arrays.toString( idsToInitialize ) );
134134
}
135135

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected void initializeEntities(
124124
SharedSessionContractImplementor session) {
125125
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
126126
MULTI_KEY_LOAD_LOGGER.tracef( "Entity ids to initialize via batch fetching (%s) %s",
127-
infoString( getLoadable().getEntityName(), pkValue ),
127+
infoString( getLoadable(), pkValue ),
128128
Arrays.toString(idsToInitialize) );
129129
}
130130

@@ -161,7 +161,7 @@ protected void initializeEntities(
161161
if ( MULTI_KEY_LOAD_LOGGER.isTraceEnabled() ) {
162162
MULTI_KEY_LOAD_LOGGER.tracef(
163163
"Processing entity batch-fetch chunk (%s) %s - %s",
164-
infoString( getLoadable().getEntityName(), pkValue ),
164+
infoString( getLoadable(), pkValue ),
165165
startIndex,
166166
startIndex + ( sqlBatchSize - 1 )
167167
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static void upgradeLock(
100100
else {
101101
throw new IllegalStateException( String.format(
102102
"Trying to lock versioned entity %s but found null version",
103-
infoString( persister.getEntityName(), entry.getId() )
103+
infoString( persister, entry.getId() )
104104
) );
105105
}
106106
}

0 commit comments

Comments
 (0)