HHH-16830: change the naming
This commit is contained in:
parent
af778c4eba
commit
4125902eea
|
@ -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`
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FilterDefinition implements Serializable {
|
|||
private final Map<String, JdbcMapping> explicitParamJaMappings = new HashMap<>();
|
||||
private final Map<String, ManagedBean<? extends Supplier<?>>> 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<String, JdbcMapping> explicitParamJaMappings,
|
||||
Map<String, ManagedBean<? extends Supplier<?>>> parameterResolverMap, boolean autoEnabled, boolean applyToLoadByKey) {
|
||||
Map<String, ManagedBean<? extends Supplier<?>>> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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<String, Filter> getEnabledFiltersForFind() {
|
||||
return getEnabledFilters()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(f -> f.getValue().isApplyToLoadByKey())
|
||||
.filter(f -> f.getValue().isApplyToLoadById())
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class FilterImpl implements Filter, Serializable {
|
|||
private final String filterName;
|
||||
private final Map<String,Object> 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<String,?> getParameters() {
|
||||
|
|
|
@ -333,7 +333,7 @@ public class FilterTest extends BaseEntityManagerFunctionalTestCase {
|
|||
name="amount",
|
||||
type=Double.class
|
||||
),
|
||||
applyToLoadByKey = true
|
||||
applyToLoadById = true
|
||||
)
|
||||
@Filter(
|
||||
name="minimumAmount",
|
||||
|
|
Loading…
Reference in New Issue