From 36fc1ad35e094df3aa42abe3a29c1798c1543414 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Mon, 4 Feb 2019 13:51:28 -0800 Subject: [PATCH] HHH-13244 : Fix EntityPrinter to log "" for uninitalized proxies --- .../org/hibernate/internal/util/EntityPrinter.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/EntityPrinter.java b/hibernate-core/src/main/java/org/hibernate/internal/util/EntityPrinter.java index f4ac35f059..09d2649b43 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/EntityPrinter.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/EntityPrinter.java @@ -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 = ""; + } + else { + strValue = types[i].toLoggableString( values[i], factory ); + } result.put( names[i], strValue ); } }