HHH-2394 Allowed usage of {alias} marker.

This commit is contained in:
Rob Worsnop 2012-06-28 10:16:29 -04:00 committed by Strong Liu
parent 1cd8db2ac3
commit 542bc5c83c
2 changed files with 6 additions and 4 deletions

View File

@ -123,10 +123,12 @@ public class FilterHelper {
private String render(FilterAliasGenerator aliasGenerator, int filterIndex){
Map<String,String> aliasTableMap = filterAliasTableMaps[filterIndex];
String condition = filterConditions[filterIndex];
if (filterAutoAliasFlags[filterIndex]){
return StringHelper.replace(filterConditions[filterIndex], FilterImpl.MARKER, aliasGenerator.getAlias(aliasTableMap.get(null)));
} else{
String condition = filterConditions[filterIndex];
return StringHelper.replace(condition, FilterImpl.MARKER, aliasGenerator.getAlias(aliasTableMap.get(null)));
} else if (isTableFromPersistentClass(aliasTableMap)){
return condition.replace("{alias}", aliasGenerator.getAlias(aliasTableMap.get(null)));
} else {
for (Map.Entry<String, String> entry : aliasTableMap.entrySet()){
condition = condition.replace("{"+entry.getKey()+"}", aliasGenerator.getAlias(entry.getValue()));
}

View File

@ -16,7 +16,7 @@ import org.hibernate.annotations.ParamDef;
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name="ZOOLOGY_ANIMAL")
@FilterDef(name="ignoreSome", parameters={@ParamDef(name="name", type="string")})
@Filter(name="ignoreSome", condition=":name <> ANIMAL_NAME")
@Filter(name="ignoreSome", deduceAliasInjectionPoints=false, condition=":name <> {alias}.ANIMAL_NAME")
public class Animal {
@Id
@GeneratedValue