1616import  org .hibernate .persister .entity .EntityPersister ;
1717import  org .hibernate .proxy .LazyInitializer ;
1818
19- import  org .jboss .logging .Logger ;
20- 
2119import  static  jakarta .persistence .spi .LoadState .NOT_LOADED ;
2220import  static  org .hibernate .engine .internal .ManagedTypeHelper .asManagedEntity ;
2321import  static  org .hibernate .engine .internal .ManagedTypeHelper .isManagedEntity ;
3028 * @author Steve Ebersole 
3129 */ 
3230public  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