HHH-2394 Remove conditions that blocked filters on sub-classes (for annotations)

This commit is contained in:
Rob Worsnop 2012-05-20 23:27:06 -04:00 committed by Strong Liu
parent 63f2639101
commit 09547a9051
3 changed files with 12 additions and 24 deletions

View File

@ -578,10 +578,7 @@ public static void bindClass(
entityBinder.setCache( determineCacheSettings( clazzToProcess, mappings ) ); entityBinder.setCache( determineCacheSettings( clazzToProcess, mappings ) );
entityBinder.setNaturalIdCache( clazzToProcess, clazzToProcess.getAnnotation( NaturalIdCache.class ) ); entityBinder.setNaturalIdCache( clazzToProcess, clazzToProcess.getAnnotation( NaturalIdCache.class ) );
//Filters are not allowed on subclasses bindFilters( clazzToProcess, entityBinder, mappings );
if ( !inheritanceState.hasParents() ) {
bindFilters( clazzToProcess, entityBinder, mappings );
}
entityBinder.bindEntity(); entityBinder.bindEntity();

View File

@ -371,24 +371,19 @@ public void bindEntity() {
persistentClass.addTuplizer( mode, tuplizer.impl().getName() ); persistentClass.addTuplizer( mode, tuplizer.impl().getName() );
} }
if ( !inheritanceState.hasParents() ) { for ( Map.Entry<String, String> filter : filters.entrySet() ) {
for ( Map.Entry<String, String> filter : filters.entrySet() ) { String filterName = filter.getKey();
String filterName = filter.getKey(); String cond = filter.getValue();
String cond = filter.getValue(); if ( BinderHelper.isEmptyAnnotationValue( cond ) ) {
if ( BinderHelper.isEmptyAnnotationValue( cond ) ) { FilterDefinition definition = mappings.getFilterDefinition( filterName );
FilterDefinition definition = mappings.getFilterDefinition( filterName ); cond = definition == null ? null : definition.getDefaultFilterCondition();
cond = definition == null ? null : definition.getDefaultFilterCondition(); if ( StringHelper.isEmpty( cond ) ) {
if ( StringHelper.isEmpty( cond ) ) { throw new AnnotationException(
throw new AnnotationException( "no filter condition found for filter " + filterName + " in " + this.name
"no filter condition found for filter " + filterName + " in " + this.name );
);
}
} }
persistentClass.addFilter( filterName, null, cond );
} }
} persistentClass.addFilter( filterName, null, cond );
else if ( filters.size() > 0 ) {
LOG.filterAnnotationOnSubclass( persistentClass.getEntityName() );
} }
LOG.debugf( "Import with entity name %s", name ); LOG.debugf( "Import with entity name %s", name );
try { try {

View File

@ -344,10 +344,6 @@ void expectedType(String name,
@Message(value = "Fetching database metadata", id = 102) @Message(value = "Fetching database metadata", id = 102)
void fetchingDatabaseMetadata(); void fetchingDatabaseMetadata();
@LogMessage(level = WARN)
@Message(value = "@Filter not allowed on subclasses (ignored): %s", id = 103)
void filterAnnotationOnSubclass(String className);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "firstResult/maxResults specified with collection fetch; applying in memory!", id = 104) @Message(value = "firstResult/maxResults specified with collection fetch; applying in memory!", id = 104)
void firstOrMaxResultsSpecifiedWithCollectionFetch(); void firstOrMaxResultsSpecifiedWithCollectionFetch();