Skip to content

Make PersistenceContextEntry#EntityStatus public for Hibernate Reactive #10550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 7.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,32 @@ private CacheLoadHelper() {
*
* @throws HibernateException Generally indicates problems applying a lock mode.
*/
public static PersistenceContextEntry loadFromSessionCache(
EntityKey keyToLoad, LockOptions lockOptions,
LoadEventListener.LoadType options,
SharedSessionContractImplementor session) {
public static PersistenceContextEntry loadFromSessionCache(EntityKey keyToLoad, LockOptions lockOptions, LoadEventListener.LoadType options, SharedSessionContractImplementor session) {
final Object old = session.getEntityUsingInterceptor( keyToLoad );
PersistenceContextEntry.EntityStatus entityStatus = MANAGED;
if ( old != null ) {
// this object was already loaded
final EntityEntry oldEntry = session.getPersistenceContext().getEntry( old );
if ( options.isCheckDeleted() ) {
if ( oldEntry.getStatus().isDeletedOrGone() ) {
LOADING_LOGGER.foundEntityScheduledForRemoval();
return new PersistenceContextEntry( old, REMOVED_ENTITY_MARKER );
}
}
if ( options.isAllowNulls() ) {
final EntityPersister persister =
session.getFactory().getMappingMetamodel()
.getEntityDescriptor( keyToLoad.getEntityName() );
if ( !persister.isInstance( old ) ) {
LOADING_LOGGER.foundEntityWrongType();
return new PersistenceContextEntry( old, INCONSISTENT_RTN_CLASS_MARKER );
}
entityStatus = entityStatus( keyToLoad, options, session, oldEntry, old );
if ( entityStatus == MANAGED ) {
upgradeLock( old, oldEntry, lockOptions, session );
}
upgradeLock( old, oldEntry, lockOptions, session );
}
return new PersistenceContextEntry( old, MANAGED );
return new PersistenceContextEntry( old, entityStatus );
}

// Used by Hibernate Reactive
public static PersistenceContextEntry.EntityStatus entityStatus(EntityKey keyToLoad, LoadEventListener.LoadType options, SharedSessionContractImplementor session, EntityEntry oldEntry, Object old) {
if ( options.isCheckDeleted() && oldEntry.getStatus().isDeletedOrGone() ) {
LOADING_LOGGER.foundEntityScheduledForRemoval();
return REMOVED_ENTITY_MARKER;
}
if ( options.isAllowNulls() && !session.getFactory().getMappingMetamodel()
.getEntityDescriptor( keyToLoad.getEntityName() ).isInstance( old ) ) {
LOADING_LOGGER.foundEntityWrongType();
return INCONSISTENT_RTN_CLASS_MARKER;
}
return MANAGED;
}

/**
Expand Down Expand Up @@ -408,7 +408,7 @@ public static boolean initializeCollectionFromCache(
}

public record PersistenceContextEntry(Object entity, EntityStatus status) {
enum EntityStatus {
public enum EntityStatus {
MANAGED,
REMOVED_ENTITY_MARKER,
INCONSISTENT_RTN_CLASS_MARKER
Expand Down
Loading