Skip to content

Commit

Permalink
promote getSession() up to PersistentCollection
Browse files Browse the repository at this point in the history
for the benefit of Hibernate Reactive, which currently casts to AbstractPersistentCollection
  • Loading branch information
gavinking committed Feb 20, 2025
1 parent e255ae6 commit a8a1ebb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,7 @@ public void afterRowInsert(CollectionPersister persister, Object entry, int i) t
@Override
public abstract Collection<E> getOrphans(Serializable snapshot, String entityName) throws HibernateException;

/**
* Get the session currently associated with this collection.
*
* @return The session
*/
@Override
public final SharedSessionContractImplementor getSession() {
return session;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ public boolean needsInserting(Object entry, int i, Type elemType) throws Hiberna
public boolean needsUpdating(Object entry, int i, Type elemType) throws HibernateException {
final Serializable sn = getSnapshot();
return i < Array.getLength( sn )
&& Array.get( sn, i ) != null
&& Array.get( array, i ) != null
&& elemType.isDirty( Array.get( array, i ), Array.get( sn, i ), getSession() );
&& Array.get( sn, i ) != null
&& Array.get( array, i ) != null
&& elemType.isDirty( Array.get( array, i ), Array.get( sn, i ), getSession() );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.hibernate.HibernateException;
import org.hibernate.Incubating;
import org.hibernate.Internal;
import org.hibernate.engine.spi.InstanceIdentity;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
Expand Down Expand Up @@ -359,7 +360,6 @@ default boolean needsUpdating(
*
* @see #injectLoadedState
*/
@SuppressWarnings("UnusedReturnValue")
boolean endRead();

/**
Expand Down Expand Up @@ -511,6 +511,13 @@ default boolean isDirectlyProvidedCollection(Object collection) {

void initializeEmptyCollection(CollectionPersister persister);

/**
* Get the session currently associated with this collection.
* Declared here for use by Hibernate Reactive.
*/
@Internal
SharedSessionContractImplementor getSession();

/**
* Is the collection newly instantiated?
*
Expand Down

0 comments on commit a8a1ebb

Please sign in to comment.