diff --git a/core/src/main/java/org/hibernate/engine/LoadQueryInfluencers.java b/core/src/main/java/org/hibernate/engine/LoadQueryInfluencers.java index 8fd471530d..b279d69b61 100644 --- a/core/src/main/java/org/hibernate/engine/LoadQueryInfluencers.java +++ b/core/src/main/java/org/hibernate/engine/LoadQueryInfluencers.java @@ -111,6 +111,14 @@ public class LoadQueryInfluencers implements Serializable { return enabledFilters; } + /** + * Returns an unmodifiable Set of enabled filter names. + * @return an unmodifiable Set of enabled filter names. + */ + public Set getEnabledFilterNames() { + return java.util.Collections.unmodifiableSet( enabledFilters.keySet() ); + } + public Filter getEnabledFilter(String filterName) { return ( Filter ) enabledFilters.get( filterName ); } diff --git a/core/src/main/java/org/hibernate/impl/SessionImpl.java b/core/src/main/java/org/hibernate/impl/SessionImpl.java index 3e490d1721..446be01988 100644 --- a/core/src/main/java/org/hibernate/impl/SessionImpl.java +++ b/core/src/main/java/org/hibernate/impl/SessionImpl.java @@ -2150,9 +2150,16 @@ public final class SessionImpl extends AbstractSessionImpl childSessionsByEntityMode = ( Map ) ois.readObject(); - Iterator iter = loadQueryInfluencers.getEnabledFilters().values().iterator(); + // LoadQueryInfluencers.getEnabledFilters() tries to validate each enabled + // filter, which will fail when called before FilterImpl.afterDeserialize( factory ); + // Instead lookup the filter by name, call FilterImpl.afterDeserialize( factory ), + // and then validate. + Iterator iter = loadQueryInfluencers.getEnabledFilterNames().iterator(); while ( iter.hasNext() ) { - ( ( FilterImpl ) iter.next() ).afterDeserialize( factory ); + String filterName = ( String ) iter.next(); + FilterImpl filter = ( FilterImpl ) loadQueryInfluencers.getEnabledFilter( filterName ); + filter.afterDeserialize( factory ); + filter.validate(); } if ( isRootSession && childSessionsByEntityMode != null ) {