diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/CollectionTypes.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/CollectionTypes.java index bb72946ad..9ce6a7c5b 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/CollectionTypes.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/CollectionTypes.java @@ -23,7 +23,6 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.spi.CollectionEntry; import org.hibernate.engine.spi.PersistenceContext; -import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; @@ -58,7 +57,7 @@ public static CompletionStage replace( CollectionType type, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) @@ -76,7 +75,7 @@ public static CompletionStage replace( CollectionType type, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache) throws HibernateException { if ( original == null ) { @@ -96,7 +95,7 @@ else if ( !Hibernate.isInitialized( original ) ) { */ private static Object replaceNullOriginal( Object target, - SessionImplementor session) { + SharedSessionContractImplementor session) { if ( target == null ) { return null; } @@ -132,7 +131,7 @@ private static Object replaceUninitializedOriginal( CollectionType type, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Map copyCache) { final PersistentCollection persistentCollection = (PersistentCollection) original; if ( persistentCollection.hasQueuedOperations() ) { @@ -165,7 +164,7 @@ private static CompletionStage replaceOriginal( CollectionType type, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache) { @@ -211,7 +210,7 @@ private static CompletionStage replaceElements( Object target, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { if ( type instanceof ArrayType ) { return replaceArrayTypeElements( type, original, target, owner, copyCache, session ); } @@ -246,7 +245,7 @@ private static CompletionStage replaceCollectionTypeElements( final Collection result, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { result.clear(); // copy elements into newly empty target collection final Type elemType = type.getElementType( session.getFactory() ); @@ -261,7 +260,7 @@ private static CompletionStage preserveSnapshotIfNecessary( Collection result, Object owner, Map copyCache, - SessionImplementor session, + SharedSessionContractImplementor session, Type elemType) { // if the original is a PersistentCollection, and that original // was not flagged as dirty, then reset the target's dirty flag @@ -293,7 +292,7 @@ private static CompletionStage replaceMapTypeElements( Map target, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final CollectionPersister persister = session.getFactory().getRuntimeMetamodels().getMappingMetamodel() .getCollectionDescriptor( type.getRole() ); @@ -320,7 +319,7 @@ private static CompletionStage replaceArrayTypeElements( Object target, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final Object result; final int length = Array.getLength( original ); if ( length != Array.getLength( target ) ) { @@ -345,7 +344,7 @@ private static CompletionStage getReplace( Type elemType, Object o, Object owner, - SessionImplementor session, + SharedSessionContractImplementor session, Map copyCache) { return getReplace( elemType, o, null, owner, session, copyCache ); } @@ -355,7 +354,7 @@ private static CompletionStage getReplace( Object object, Object target, Object owner, - SessionImplementor session, + SharedSessionContractImplementor session, Map copyCache) { return elemType instanceof EntityType entityType ? EntityTypes.replace( entityType, object, target, session, owner, copyCache ) @@ -371,7 +370,7 @@ private static CompletionStage preserveSnapshot( Type elemType, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final CollectionEntry ce = session.getPersistenceContextInternal().getCollectionEntry( result ); if ( ce != null ) { return createSnapshot( original, result, elemType, owner, copyCache, session ) @@ -391,7 +390,7 @@ private static CompletionStage createSnapshot( Type elemType, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final Serializable originalSnapshot = original.getStoredSnapshot(); if ( originalSnapshot instanceof List list ) { return createListSnapshot( list, elemType, owner, copyCache, session ); @@ -416,7 +415,7 @@ private static CompletionStage createArraySnapshot( Type elemType, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { return loop( 0, array.length, i -> getReplace( elemType, array[i], owner, session, copyCache ) .thenAccept( o -> array[i] = o ) @@ -432,7 +431,7 @@ private static CompletionStage createMapSnapshot( Type elemType, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final Map resultSnapshot = (Map) result.getStoredSnapshot(); final Map targetMap = map instanceof SortedMap sortedMap @@ -457,7 +456,7 @@ private static CompletionStage createListSnapshot( Type elemType, Object owner, Map copyCache, - SessionImplementor session) { + SharedSessionContractImplementor session) { final ArrayList targetList = new ArrayList<>( list.size() ); return loop( list, obj -> getReplace( elemType, obj, owner, session, copyCache ) diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java index 9176e853c..504830150 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java @@ -16,7 +16,6 @@ import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.PersistentAttributeInterceptor; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.persister.entity.EntityPersister; @@ -155,7 +154,7 @@ public static CompletionStage replace( final Object[] original, final Object[] target, final Type[] types, - final SessionImplementor session, + final SharedSessionContractImplementor session, final Object owner, final Map copyCache) { Object[] copied = new Object[original.length]; @@ -171,7 +170,7 @@ public static CompletionStage replace( final Object[] original, final Object[] target, final Type[] types, - final SessionImplementor session, + final SharedSessionContractImplementor session, final Object owner, final Map copyCache, final ForeignKeyDirection foreignKeyDirection) { @@ -188,7 +187,7 @@ private static CompletionStage replace( EntityType entityType, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) @@ -208,7 +207,7 @@ protected static CompletionStage replace( EntityType entityType, Object original, Object target, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache) { if ( original == null ) { @@ -254,7 +253,7 @@ protected static CompletionStage replace( private static CompletionStage resolveIdOrUniqueKey( EntityType entityType, Object original, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache) { return getIdentifier( entityType, original, session ) @@ -289,7 +288,7 @@ private static CompletionStage resolveIdOrUniqueKey( private static CompletionStage getIdentifier( EntityType entityType, Object value, - SessionImplementor session) { + SharedSessionContractImplementor session) { if ( entityType.isReferenceToIdentifierProperty() ) { // tolerates nulls return getEntityIdentifierIfNotUnsaved( entityType.getAssociatedEntityName(), value, session ); @@ -358,7 +357,7 @@ private static CompletionStage getIdentifierFromHibernateProxy( // an entity type, in which case we need to resolve its identifier final AttributeMapping type = entityPersister.findAttributeMapping( uniqueKeyPropertyName ); if ( type.isEntityIdentifierMapping() ) { - propertyValue = getIdentifier( (EntityType) type, propertyValue, (SessionImplementor) session ); + propertyValue = getIdentifier( (EntityType) type, propertyValue, session ); } return propertyValue; } @@ -389,7 +388,7 @@ private static CompletionStage replace( Object[] original, Object[] target, Type[] types, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache, int i, @@ -435,7 +434,7 @@ private static CompletionStage replace( Object[] original, Object[] target, Type[] types, - SessionImplementor session, + SharedSessionContractImplementor session, Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection, diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ForeignKeys.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ForeignKeys.java index 087623e44..87078f87f 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ForeignKeys.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ForeignKeys.java @@ -15,7 +15,6 @@ import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SelfDirtinessTracker; -import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.StringHelper; import org.hibernate.persister.entity.EntityPersister; @@ -48,7 +47,7 @@ public final class ForeignKeys { public static class Nullifier { private final boolean isDelete; private final boolean isEarlyInsert; - private final SessionImplementor session; + private final SharedSessionContractImplementor session; private final Object self; private final EntityPersister persister; @@ -65,7 +64,7 @@ public Nullifier( final Object self, final boolean isDelete, final boolean isEarlyInsert, - final SessionImplementor session, + final SharedSessionContractImplementor session, final EntityPersister persister) { this.isDelete = isDelete; this.isEarlyInsert = isEarlyInsert; @@ -270,7 +269,7 @@ private CompletionStage isNullifiable(final String entityName, Object o * * @return {@code true} if the given entity is not transient (meaning it is either detached/persistent) */ - public static CompletionStage isNotTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) { + public static CompletionStage isNotTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session) { if ( isHibernateProxy( entity ) ) { return trueFuture(); } @@ -297,7 +296,7 @@ public static CompletionStage isNotTransient(String entityName, Object * * @return {@code true} if the given entity is transient (unsaved) */ - public static CompletionStage isTransient(String entityName, Object entity, Boolean assumed, SessionImplementor session) { + public static CompletionStage isTransient(String entityName, Object entity, Boolean assumed, SharedSessionContractImplementor session) { if ( entity == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { // an unfetched association can only point to // an entity that already exists in the db @@ -350,7 +349,7 @@ public static CompletionStage isTransient(String entityName, Object ent public static CompletionStage getEntityIdentifierIfNotUnsaved( final String entityName, final Object object, - final SessionImplementor session) throws TransientObjectException { + final SharedSessionContractImplementor session) throws TransientObjectException { if ( object == null ) { return nullFuture(); } @@ -387,7 +386,7 @@ public static CompletionStage findNonNullableT final EntityPersister persister = session.getEntityPersister( entityName, entity ); final Type[] types = persister.getPropertyTypes(); - final Nullifier nullifier = new Nullifier( entity, false, isEarlyInsert, (SessionImplementor) session, persister ); + final Nullifier nullifier = new Nullifier( entity, false, isEarlyInsert, session, persister ); final String[] propertyNames = persister.getPropertyNames(); final boolean[] nullability = persister.getPropertyNullability(); final NonNullableTransientDependencies nonNullableTransientEntities = new NonNullableTransientDependencies(); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java index 4838e6971..3f40cdb86 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/ReactiveEntityInsertAction.java @@ -16,7 +16,6 @@ import org.hibernate.engine.spi.EntityHolder; 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.engine.spi.Status; import org.hibernate.persister.entity.EntityPersister; @@ -64,7 +63,7 @@ public interface ReactiveEntityInsertAction extends ReactiveExecutable, Comparab // @see org.hibernate.action.internal.AbstractEntityInsertAction#nullifyTransientReferencesIfNotAlready() default CompletionStage reactiveNullifyTransientReferencesIfNotAlready() { if ( !areTransientReferencesNullified() ) { - return new ForeignKeys.Nullifier( getInstance(), false, isEarlyInsert(), (SessionImplementor) getSession(), getPersister() ) + return new ForeignKeys.Nullifier( getInstance(), false, isEarlyInsert(), getSession(), getPersister() ) .nullifyTransientReferences( getState() ) .thenAccept( v -> { new Nullability( getSession() ).checkNullability( getState(), getPersister(), false ); diff --git a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveSession.java b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveSession.java index dbb7a818f..ab2089c0d 100644 --- a/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveSession.java +++ b/hibernate-reactive-core/src/main/java/org/hibernate/reactive/session/ReactiveSession.java @@ -44,6 +44,7 @@ public interface ReactiveSession extends ReactiveQueryProducer, ReactiveSharedSe ReactiveActionQueue getReactiveActionQueue(); + @Override SessionImplementor getSharedContract(); CompletionStage reactiveFetch(E entity, Attribute field);