HHH-13485 FilterJoinTable does not to use the defualt condition
This commit is contained in:
parent
41abc8d9f0
commit
b18c967cf6
|
@ -103,6 +103,7 @@ import org.hibernate.cfg.PropertyInferredData;
|
||||||
import org.hibernate.cfg.PropertyPreloadedData;
|
import org.hibernate.cfg.PropertyPreloadedData;
|
||||||
import org.hibernate.cfg.SecondPass;
|
import org.hibernate.cfg.SecondPass;
|
||||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||||
|
import org.hibernate.engine.spi.FilterDefinition;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
@ -1364,10 +1365,25 @@ public abstract class CollectionBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFilter(boolean hasAssociationTable, FilterJoinTable filter) {
|
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(
|
collection.addFilter(
|
||||||
filter.name(),
|
filter.name(),
|
||||||
filter.condition(),
|
condition,
|
||||||
filter.deduceAliasInjectionPoints(),
|
filter.deduceAliasInjectionPoints(),
|
||||||
toAliasTableMap( filter.aliases() ),
|
toAliasTableMap( filter.aliases() ),
|
||||||
toAliasEntityMap( filter.aliases() )
|
toAliasEntityMap( filter.aliases() )
|
||||||
|
|
Loading…
Reference in New Issue