Fix java.lang.ClassCastException: org.hibernate.internal.StatelessSessionImpl cannot be cast to org.hibernate.event.spi.EventSource

This commit is contained in:
Andrea Boriero 2021-10-04 21:04:51 +02:00
parent a3920e5892
commit 7eccda9f36
3 changed files with 6 additions and 3 deletions

View File

@ -11,6 +11,7 @@ import java.io.Serializable;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.service.spi.EventListenerRegistry;

View File

@ -301,7 +301,7 @@ public class CacheEntityLoaderHelper {
private Object convertCacheReferenceEntryToEntity(
ReferenceCacheEntryImpl referenceCacheEntry,
EventSource session,
SharedSessionContractImplementor session,
EntityKey entityKey) {
final Object entity = referenceCacheEntry.getReference();
@ -317,7 +317,7 @@ public class CacheEntityLoaderHelper {
private void makeEntityCircularReferenceSafe(
ReferenceCacheEntryImpl referenceCacheEntry,
EventSource session,
SharedSessionContractImplementor session,
Object entity,
EntityKey entityKey) {

View File

@ -12,6 +12,8 @@ import org.hibernate.LockMode;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.log.LoggingHelper;
import org.hibernate.loader.entity.CacheEntityLoaderHelper;
@ -104,7 +106,7 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
final Object cachedEntity;
if ( concreteDescriptor.getEntityMetamodel().hasSubclasses() ) {
cachedEntity = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache(
(EventSource) rowProcessingState.getSession(),
(SharedSessionContractImplementor) rowProcessingState.getSession(),
null,
LockMode.NONE,
concreteDescriptor,