HHH-13244 : Fix EntityPrinter to log "<uninitialized>" for uninitalized proxies

This commit is contained in:
Gail Badner 2019-02-04 13:51:28 -08:00
parent 80ff6b4fe6
commit 36fc1ad35e
1 changed files with 11 additions and 3 deletions

View File

@ -9,6 +9,7 @@ package org.hibernate.internal.util;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
import org.hibernate.engine.spi.EntityKey;
@ -61,9 +62,16 @@ public final class EntityPrinter {
Object[] values = entityPersister.getPropertyValues( entity );
for ( int i = 0; i < types.length; i++ ) {
if ( !names[i].startsWith( "_" ) ) {
String strValue = values[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ?
values[i].toString() :
types[i].toLoggableString( values[i], factory );
final String strValue;
if ( values[i] == LazyPropertyInitializer.UNFETCHED_PROPERTY ) {
strValue = values[i].toString();
}
else if ( !Hibernate.isInitialized( values[i] ) ) {
strValue = "<uninitialized>";
}
else {
strValue = types[i].toLoggableString( values[i], factory );
}
result.put( names[i], strValue );
}
}