Skip to content

Commit

Permalink
get rid of extremely useless log messages
Browse files Browse the repository at this point in the history
These messages were added in HHH-7454 and HHH-11426.

- I'm pretty sure that the claim made in HHH-7454 is simply incorrect,
  whereas the message added in
- On the other hand, HHH-11426 is warning about an error that might,
  but probably won't occur.
  • Loading branch information
gavinking committed Feb 26, 2025
1 parent e61b5f0 commit 057e574
Showing 1 changed file with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.LazyInitializer;

import org.jboss.logging.Logger;

import static jakarta.persistence.spi.LoadState.NOT_LOADED;
import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity;
import static org.hibernate.engine.internal.ManagedTypeHelper.isManagedEntity;
Expand All @@ -30,7 +28,6 @@
* @author Steve Ebersole
*/
public class PersistenceUnitUtilImpl implements PersistenceUnitUtil, Serializable {
private static final Logger log = Logger.getLogger( PersistenceUnitUtilImpl.class );

private final SessionFactoryImplementor sessionFactory;
private final transient PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
Expand All @@ -41,16 +38,11 @@ public PersistenceUnitUtilImpl(SessionFactoryImplementor sessionFactory) {

@Override
public boolean isLoaded(Object entity, String attributeName) {
// added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate.
log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" );
switch ( isLoadedWithoutReference( entity, attributeName, cache ) ) {
case LOADED:
return true;
case NOT_LOADED:
return false;
default:
return isLoadedWithReference( entity, attributeName, cache ) != NOT_LOADED;
}
return switch ( isLoadedWithoutReference( entity, attributeName, cache ) ) {
case LOADED -> true;
case NOT_LOADED -> false;
default -> isLoadedWithReference( entity, attributeName, cache ) != NOT_LOADED;
};
}

@Override
Expand All @@ -60,8 +52,6 @@ public <E> boolean isLoaded(E entity, Attribute<? super E, ?> attribute) {

@Override
public boolean isLoaded(Object entity) {
// added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate.
log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" );
return getLoadState( entity ) != NOT_LOADED;
}

Expand Down Expand Up @@ -106,17 +96,10 @@ else if ( isManagedEntity( entity ) ) {
return entityEntry.getId();
}
else {
// HHH-11426 - best effort to deal with the case of detached entities
log.debug( "jakarta.persistence.PersistenceUnitUtil.getIdentifier may not be able to read identifier of a detached entity" );
return getIdentifierFromPersister( entity );
}
}
else {
log.debug(
"jakarta.persistence.PersistenceUnitUtil.getIdentifier is only intended to work with enhanced entities " +
"(although Hibernate also adapts this support to its proxies); " +
"however the passed entity was not enhanced (nor a proxy).. may not be able to read identifier"
);
return getIdentifierFromPersister( entity );
}
}
Expand Down

0 comments on commit 057e574

Please sign in to comment.