@@ -77,32 +77,32 @@ private CacheLoadHelper() {
77
77
*
78
78
* @throws HibernateException Generally indicates problems applying a lock mode.
79
79
*/
80
- public static PersistenceContextEntry loadFromSessionCache (
81
- EntityKey keyToLoad , LockOptions lockOptions ,
82
- LoadEventListener .LoadType options ,
83
- SharedSessionContractImplementor session ) {
80
+ public static PersistenceContextEntry loadFromSessionCache (EntityKey keyToLoad , LockOptions lockOptions , LoadEventListener .LoadType options , SharedSessionContractImplementor session ) {
84
81
final Object old = session .getEntityUsingInterceptor ( keyToLoad );
82
+ PersistenceContextEntry .EntityStatus entityStatus = MANAGED ;
85
83
if ( old != null ) {
86
84
// this object was already loaded
87
85
final EntityEntry oldEntry = session .getPersistenceContext ().getEntry ( old );
88
- if ( options .isCheckDeleted () ) {
89
- if ( oldEntry .getStatus ().isDeletedOrGone () ) {
90
- LOADING_LOGGER .foundEntityScheduledForRemoval ();
91
- return new PersistenceContextEntry ( old , REMOVED_ENTITY_MARKER );
92
- }
93
- }
94
- if ( options .isAllowNulls () ) {
95
- final EntityPersister persister =
96
- session .getFactory ().getMappingMetamodel ()
97
- .getEntityDescriptor ( keyToLoad .getEntityName () );
98
- if ( !persister .isInstance ( old ) ) {
99
- LOADING_LOGGER .foundEntityWrongType ();
100
- return new PersistenceContextEntry ( old , INCONSISTENT_RTN_CLASS_MARKER );
101
- }
86
+ entityStatus = entityStatus ( keyToLoad , options , session , oldEntry , old );
87
+ if ( entityStatus == MANAGED ) {
88
+ upgradeLock ( old , oldEntry , lockOptions , session );
102
89
}
103
- upgradeLock ( old , oldEntry , lockOptions , session );
104
90
}
105
- return new PersistenceContextEntry ( old , MANAGED );
91
+ return new PersistenceContextEntry ( old , entityStatus );
92
+ }
93
+
94
+ // Used by Hibernate Reactive
95
+ public static PersistenceContextEntry .EntityStatus entityStatus (EntityKey keyToLoad , LoadEventListener .LoadType options , SharedSessionContractImplementor session , EntityEntry oldEntry , Object old ) {
96
+ if ( options .isCheckDeleted () && oldEntry .getStatus ().isDeletedOrGone () ) {
97
+ LOADING_LOGGER .foundEntityScheduledForRemoval ();
98
+ return REMOVED_ENTITY_MARKER ;
99
+ }
100
+ if ( options .isAllowNulls () && !session .getFactory ().getMappingMetamodel ()
101
+ .getEntityDescriptor ( keyToLoad .getEntityName () ).isInstance ( old ) ) {
102
+ LOADING_LOGGER .foundEntityWrongType ();
103
+ return INCONSISTENT_RTN_CLASS_MARKER ;
104
+ }
105
+ return MANAGED ;
106
106
}
107
107
108
108
/**
0 commit comments