Skip to content

Commit 057e574

Browse files
committed
get rid of extremely useless log messages
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.
1 parent e61b5f0 commit 057e574

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

hibernate-core/src/main/java/org/hibernate/jpa/internal/PersistenceUnitUtilImpl.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import org.hibernate.persister.entity.EntityPersister;
1717
import org.hibernate.proxy.LazyInitializer;
1818

19-
import org.jboss.logging.Logger;
20-
2119
import static jakarta.persistence.spi.LoadState.NOT_LOADED;
2220
import static org.hibernate.engine.internal.ManagedTypeHelper.asManagedEntity;
2321
import static org.hibernate.engine.internal.ManagedTypeHelper.isManagedEntity;
@@ -30,7 +28,6 @@
3028
* @author Steve Ebersole
3129
*/
3230
public class PersistenceUnitUtilImpl implements PersistenceUnitUtil, Serializable {
33-
private static final Logger log = Logger.getLogger( PersistenceUnitUtilImpl.class );
3431

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

4239
@Override
4340
public boolean isLoaded(Object entity, String attributeName) {
44-
// added log message to help with HHH-7454, if state == LoadState,NOT_LOADED, returning true or false is not accurate.
45-
log.debug( "PersistenceUnitUtil#isLoaded is not always accurate; consider using EntityManager#contains instead" );
46-
switch ( isLoadedWithoutReference( entity, attributeName, cache ) ) {
47-
case LOADED:
48-
return true;
49-
case NOT_LOADED:
50-
return false;
51-
default:
52-
return isLoadedWithReference( entity, attributeName, cache ) != NOT_LOADED;
53-
}
41+
return switch ( isLoadedWithoutReference( entity, attributeName, cache ) ) {
42+
case LOADED -> true;
43+
case NOT_LOADED -> false;
44+
default -> isLoadedWithReference( entity, attributeName, cache ) != NOT_LOADED;
45+
};
5446
}
5547

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

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

@@ -106,17 +96,10 @@ else if ( isManagedEntity( entity ) ) {
10696
return entityEntry.getId();
10797
}
10898
else {
109-
// HHH-11426 - best effort to deal with the case of detached entities
110-
log.debug( "jakarta.persistence.PersistenceUnitUtil.getIdentifier may not be able to read identifier of a detached entity" );
11199
return getIdentifierFromPersister( entity );
112100
}
113101
}
114102
else {
115-
log.debug(
116-
"jakarta.persistence.PersistenceUnitUtil.getIdentifier is only intended to work with enhanced entities " +
117-
"(although Hibernate also adapts this support to its proxies); " +
118-
"however the passed entity was not enhanced (nor a proxy).. may not be able to read identifier"
119-
);
120103
return getIdentifierFromPersister( entity );
121104
}
122105
}

0 commit comments

Comments
 (0)