From 4125902eeadce088ab12bf919b635b7aa332fac8 Mon Sep 17 00:00:00 2001 From: Dmitrii Karmanov Date: Mon, 27 May 2024 10:39:13 +0200 Subject: [PATCH] HHH-16830: change the naming --- .../userguide/chapters/pc/PersistenceContext.adoc | 4 ++-- hibernate-core/src/main/java/org/hibernate/Filter.java | 4 ++-- .../main/java/org/hibernate/annotations/FilterDef.java | 2 +- .../hibernate/boot/model/internal/FilterDefBinder.java | 2 +- .../org/hibernate/engine/spi/FilterDefinition.java | 10 +++++----- .../org/hibernate/engine/spi/LoadQueryInfluencers.java | 6 +++--- .../main/java/org/hibernate/internal/FilterImpl.java | 8 ++++---- .../java/org/hibernate/orm/test/pc/FilterTest.java | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/documentation/src/main/asciidoc/userguide/chapters/pc/PersistenceContext.adoc b/documentation/src/main/asciidoc/userguide/chapters/pc/PersistenceContext.adoc index bcd9b72441..cc6471b394 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/pc/PersistenceContext.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/pc/PersistenceContext.adoc @@ -558,11 +558,11 @@ include::{example-dir-pc}/FilterTest.java[tags=pc-filter-resolver-Account-exampl [IMPORTANT] ==== -Filters apply to entity queries, but not to direct fetching, unless otherwise configured using the `applyToLoadByKey` flag +Filters apply to entity queries, but not to direct fetching, unless otherwise configured using the `applyToLoadById` flag on the `@FilterDef`, that should be set to `true` in order to activate the filter with direct fetching. Therefore, in the following example, the `activeAccount` filter is not taken into consideration when fetching an entity from the Persistence Context. -On the other hand, the `minimumAmount` filter is taken into consideration, because its `applyToLoadByKey` flag is set to `true`. +On the other hand, the `minimumAmount` filter is taken into consideration, because its `applyToLoadById` flag is set to `true`. [[pc-filter-entity-example]] .Fetching entities mapped with `@Filter` diff --git a/hibernate-core/src/main/java/org/hibernate/Filter.java b/hibernate-core/src/main/java/org/hibernate/Filter.java index ef1683227d..990b0b44ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/Filter.java +++ b/hibernate-core/src/main/java/org/hibernate/Filter.java @@ -97,10 +97,10 @@ public interface Filter { boolean isAutoEnabled(); /** - * Get the associated {@link FilterDefinition applyToLoadByKey} of this + * Get the associated {@link FilterDefinition applyToLoadById} of this * named filter. * * @return The flag value */ - boolean isApplyToLoadByKey(); + boolean isApplyToLoadById(); } diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java index 154b8d4d7a..4536a4e3bf 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/FilterDef.java @@ -103,5 +103,5 @@ public @interface FilterDef { * If the flag is true, the filter will be * applied on direct fetches, such as findById(). */ - boolean applyToLoadByKey() default false; + boolean applyToLoadById() default false; } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java index 1e968b41e6..29902afcad 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FilterDefBinder.java @@ -93,7 +93,7 @@ class FilterDefBinder { explicitParamJaMappings, parameterResolvers, filterDef.autoEnabled(), - filterDef.applyToLoadByKey() + filterDef.applyToLoadById() ); LOG.debugf( "Binding filter definition: %s", filterDefinition.getFilterName() ); context.getMetadataCollector().addFilterDefinition( filterDefinition ); diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/FilterDefinition.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/FilterDefinition.java index 484f3bc2fc..527a1426c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/FilterDefinition.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/FilterDefinition.java @@ -37,7 +37,7 @@ public class FilterDefinition implements Serializable { private final Map explicitParamJaMappings = new HashMap<>(); private final Map>> parameterResolverMap = new HashMap<>(); private final boolean autoEnabled; - private final boolean applyToLoadByKey; + private final boolean applyToLoadById; /** * Construct a new FilterDefinition instance. @@ -50,13 +50,13 @@ public class FilterDefinition implements Serializable { public FilterDefinition( String name, String defaultCondition, @Nullable Map explicitParamJaMappings, - Map>> parameterResolverMap, boolean autoEnabled, boolean applyToLoadByKey) { + Map>> parameterResolverMap, boolean autoEnabled, boolean applyToLoadById) { this.filterName = name; this.defaultFilterCondition = defaultCondition; if ( explicitParamJaMappings != null ) { this.explicitParamJaMappings.putAll( explicitParamJaMappings ); } - this.applyToLoadByKey = applyToLoadByKey; + this.applyToLoadById = applyToLoadById; if ( parameterResolverMap != null ) { this.parameterResolverMap.putAll( parameterResolverMap ); } @@ -109,8 +109,8 @@ public class FilterDefinition implements Serializable { * * @return The flag value. */ - public boolean isApplyToLoadByKey() { - return applyToLoadByKey; + public boolean isApplyToLoadById() { + return applyToLoadById; } /** diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java index a52c8e680a..8b6396c5c3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java @@ -170,16 +170,16 @@ public class LoadQueryInfluencers implements Serializable { } /** - * Returns a Map of enabled filters that have the applyToLoadByKey + * Returns a Map of enabled filters that have the applyToLoadById * flag set to true - * @return a Map of enabled filters that have the applyToLoadByKey + * @return a Map of enabled filters that have the applyToLoadById * flag set to true */ public Map getEnabledFiltersForFind() { return getEnabledFilters() .entrySet() .stream() - .filter(f -> f.getValue().isApplyToLoadByKey()) + .filter(f -> f.getValue().isApplyToLoadById()) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FilterImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/FilterImpl.java index f90b16f7c0..0cd8d9aec9 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FilterImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FilterImpl.java @@ -32,7 +32,7 @@ public class FilterImpl implements Filter, Serializable { private final String filterName; private final Map parameters = new HashMap<>(); private final boolean autoEnabled; - private final boolean applyToLoadByKey; + private final boolean applyToLoadById; void afterDeserialize(SessionFactoryImplementor factory) { definition = factory.getFilterDefinition( filterName ); @@ -48,7 +48,7 @@ public class FilterImpl implements Filter, Serializable { this.definition = configuration; filterName = definition.getFilterName(); this.autoEnabled = definition.isAutoEnabled(); - this.applyToLoadByKey = definition.isApplyToLoadByKey(); + this.applyToLoadById = definition.isApplyToLoadById(); } public FilterDefinition getFilterDefinition() { @@ -80,8 +80,8 @@ public class FilterImpl implements Filter, Serializable { * * @return The flag value. */ - public boolean isApplyToLoadByKey() { - return applyToLoadByKey; + public boolean isApplyToLoadById() { + return applyToLoadById; } public Map getParameters() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/pc/FilterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/pc/FilterTest.java index db1894fd72..ac3a1521d0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/pc/FilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/pc/FilterTest.java @@ -333,7 +333,7 @@ public class FilterTest extends BaseEntityManagerFunctionalTestCase { name="amount", type=Double.class ), - applyToLoadByKey = true + applyToLoadById = true ) @Filter( name="minimumAmount",