16
16
import org .hibernate .persister .entity .EntityPersister ;
17
17
import org .hibernate .proxy .LazyInitializer ;
18
18
19
- import org .jboss .logging .Logger ;
20
-
21
19
import static jakarta .persistence .spi .LoadState .NOT_LOADED ;
22
20
import static org .hibernate .engine .internal .ManagedTypeHelper .asManagedEntity ;
23
21
import static org .hibernate .engine .internal .ManagedTypeHelper .isManagedEntity ;
30
28
* @author Steve Ebersole
31
29
*/
32
30
public class PersistenceUnitUtilImpl implements PersistenceUnitUtil , Serializable {
33
- private static final Logger log = Logger .getLogger ( PersistenceUnitUtilImpl .class );
34
31
35
32
private final SessionFactoryImplementor sessionFactory ;
36
33
private final transient PersistenceUtilHelper .MetadataCache cache = new PersistenceUtilHelper .MetadataCache ();
@@ -41,16 +38,11 @@ public PersistenceUnitUtilImpl(SessionFactoryImplementor sessionFactory) {
41
38
42
39
@ Override
43
40
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
+ };
54
46
}
55
47
56
48
@ Override
@@ -60,8 +52,6 @@ public <E> boolean isLoaded(E entity, Attribute<? super E, ?> attribute) {
60
52
61
53
@ Override
62
54
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" );
65
55
return getLoadState ( entity ) != NOT_LOADED ;
66
56
}
67
57
@@ -106,17 +96,10 @@ else if ( isManagedEntity( entity ) ) {
106
96
return entityEntry .getId ();
107
97
}
108
98
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" );
111
99
return getIdentifierFromPersister ( entity );
112
100
}
113
101
}
114
102
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
- );
120
103
return getIdentifierFromPersister ( entity );
121
104
}
122
105
}
0 commit comments