HHH-13587 Review formatting and logging style of StatefulPersistenceContext

This commit is contained in:
Sanne Grinovero 2019-08-17 13:55:29 +01:00 committed by Sanne Grinovero
parent d065888140
commit eb675e1c7f
1 changed files with 22 additions and 22 deletions

View File

@ -58,6 +58,7 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.ConcurrentReferenceHashMap; import org.hibernate.internal.util.collections.ConcurrentReferenceHashMap;
import org.hibernate.internal.util.collections.IdentityMap; import org.hibernate.internal.util.collections.IdentityMap;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
@ -78,6 +79,7 @@ import org.jboss.logging.Logger;
* their processing. * their processing.
* *
* @author Steve Ebersole * @author Steve Ebersole
* @author Sanne Grinovero
*/ */
public class StatefulPersistenceContext implements PersistenceContext { public class StatefulPersistenceContext implements PersistenceContext {
private static final CoreMessageLogger LOG = Logger.getMessageLogger( private static final CoreMessageLogger LOG = Logger.getMessageLogger(
@ -938,9 +940,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override @Override
public void initializeNonLazyCollections() throws HibernateException { public void initializeNonLazyCollections() throws HibernateException {
if ( loadCounter == 0 ) { if ( loadCounter == 0 ) {
if ( LOG.isTraceEnabled() ) {
LOG.trace( "Initializing non-lazy collections" ); LOG.trace( "Initializing non-lazy collections" );
}
//do this work only at the very highest level of the load //do this work only at the very highest level of the load
//don't let this method be called recursively //don't let this method be called recursively
@ -1278,8 +1278,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override @Override
public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) { public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) {
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( entity ); final MetamodelImplementor metamodel = session.getFactory().getMetamodel();
final CollectionPersister cp = session.getFactory().getMetamodel().collectionPersister( entity + '.' + property ); final EntityPersister persister = metamodel.entityPersister( entity );
final CollectionPersister cp = metamodel.collectionPersister( entity + '.' + property );
// try cache lookup first // try cache lookup first
final Object parent = parentsByChild.get( childEntity ); final Object parent = parentsByChild.get( childEntity );
@ -1415,11 +1416,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
} }
private void setProxyReadOnly(HibernateProxy proxy, boolean readOnly) { private void setProxyReadOnly(HibernateProxy proxy, boolean readOnly) {
if ( proxy.getHibernateLazyInitializer().getSession() != getSession() ) { final LazyInitializer hibernateLazyInitializer = proxy.getHibernateLazyInitializer();
if ( hibernateLazyInitializer.getSession() != getSession() ) {
throw new AssertionFailure( throw new AssertionFailure(
"Attempt to set a proxy to read-only that is associated with a different session" ); "Attempt to set a proxy to read-only that is associated with a different session" );
} }
proxy.getHibernateLazyInitializer().setReadOnly( readOnly ); hibernateLazyInitializer.setReadOnly( readOnly );
} }
private void setEntityReadOnly(Object entity, boolean readOnly) { private void setEntityReadOnly(Object entity, boolean readOnly) {
@ -1461,9 +1463,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
* @throws IOException serialization errors. * @throws IOException serialization errors.
*/ */
public void serialize(ObjectOutputStream oos) throws IOException { public void serialize(ObjectOutputStream oos) throws IOException {
if ( LOG.isTraceEnabled() ) {
LOG.trace( "Serializing persistence-context" ); LOG.trace( "Serializing persistence-context" );
}
oos.writeBoolean( defaultReadOnly ); oos.writeBoolean( defaultReadOnly );
oos.writeBoolean( hasNonReadOnlyEntities ); oos.writeBoolean( hasNonReadOnlyEntities );
@ -1556,9 +1556,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
public static StatefulPersistenceContext deserialize( public static StatefulPersistenceContext deserialize(
ObjectInputStream ois, ObjectInputStream ois,
SessionImplementor session) throws IOException, ClassNotFoundException { SessionImplementor session) throws IOException, ClassNotFoundException {
if ( LOG.isTraceEnabled() ) {
LOG.trace( "Deserializing persistence-context" ); LOG.trace( "Deserializing persistence-context" );
}
final StatefulPersistenceContext rtn = new StatefulPersistenceContext( session ); final StatefulPersistenceContext rtn = new StatefulPersistenceContext( session );
SessionFactoryImplementor sfi = session.getFactory(); SessionFactoryImplementor sfi = session.getFactory();
@ -1914,10 +1912,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
break; break;
} }
default: { default: {
if ( LOG.isDebugEnabled() ) {
LOG.debug( "Unexpected CachedNaturalIdValueSource [" + source + "]" ); LOG.debug( "Unexpected CachedNaturalIdValueSource [" + source + "]" );
} }
} }
} }
}
@Override @Override
public Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] state) { public Object[] removeLocalNaturalIdCrossReference(EntityPersister persister, Serializable id, Object[] state) {