Skip to content

Commit

Permalink
HHH-13485 FilterJoinTable does not to use the defualt condition
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 committed Sep 1, 2022
1 parent 41abc8d commit b18c967
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.cfg.SecondPass;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
Expand Down Expand Up @@ -1364,10 +1365,25 @@ private void handleWhere(boolean hasAssociationTable) {
}

private void addFilter(boolean hasAssociationTable, FilterJoinTable filter) {
if (hasAssociationTable) {
if ( hasAssociationTable ) {
final String condition;
if ( StringHelper.isEmpty( filter.condition() ) ) {
final FilterDefinition filterDefinition = buildingContext.getMetadataCollector()
.getFilterDefinition( filter.name() );
if ( filterDefinition == null ) {
throw new AnnotationException(
"@FilterJoinTable on an association without condition attribute and without an any @FilterDef with a default condition"
+ StringHelper.qualify( propertyHolder.getPath(), propertyName )
);
}
condition = filterDefinition.getDefaultFilterCondition();
}
else {
condition = filter.condition();
}
collection.addFilter(
filter.name(),
filter.condition(),
condition,
filter.deduceAliasInjectionPoints(),
toAliasTableMap( filter.aliases() ),
toAliasEntityMap( filter.aliases() )
Expand Down

0 comments on commit b18c967

Please sign in to comment.