HHH-11344 : Prevent NPE when running with log on trace level
(cherry picked from commit 4ceb71f08a
)
This commit is contained in:
parent
1ecc926fa1
commit
4cc22a679d
|
@ -8,6 +8,7 @@ package org.hibernate.pretty;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
|
@ -260,8 +261,9 @@ public final class MessageHelper {
|
|||
ownerKey = collectionKey;
|
||||
}
|
||||
else {
|
||||
ownerKey = session.getPersistenceContext()
|
||||
.getEntry( collection.getOwner() ).getId();
|
||||
Object collectionOwner = collection == null ? null : collection.getOwner();
|
||||
EntityEntry entry = collectionOwner == null ? null : session.getPersistenceContext().getEntry(collectionOwner);
|
||||
ownerKey = entry == null ? null : entry.getId();
|
||||
}
|
||||
s.append( ownerIdentifierType.toLoggableString(
|
||||
ownerKey, session.getFactory() ) );
|
||||
|
|
Loading…
Reference in New Issue