https://github.com/hibernate/hibernate-orm/pull/339
It seemed that the challenge to overcome was that Hibernate did not know which aliases to use when generating the where clauses for filters. When filters are not allowed on subclasses (current situation), the alias for the root entity is used for all where clauses. So when FilterHelper is asked to render the filters, it does so with a single alias string. So my changes revolve around two themes: 1. Remembering the filter's associated table so that we can generate an appropriate alias. This was done by replacing the name->condition map with a list of FilterConfiguration objects. This is a new class and includes a qualified table name (as well as the name and condition, of course). 2. Passing a callback (instead of the alias string) to FilterHelper.render() that allows it to generate an appropriate alias for each filter, depending on table name. The callback is an implementation of a new interface, FilterAliasGenerator. The implementation varies by context. Where filters are applied to entities, we know the table name. When filters are applied to collections we do not. My solution to this is potentially controversial and I'd be interested in hearing alternatives to it. I have expanded the @Filter annotation to include a table name. This is an optional element because it makes no sense when @Filter is applied directly to an entity. That's what I don't like about this idea. For example: @OneToMany(mappedBy="club") @Filters({ @Filter(name="iqMin", table="ZOOLOGY_HUMAN", condition="HUMAN_IQ >= :min"), @Filter(name="pregnantMembers", table="ZOOLOGY_MAMMAL", condition="IS_PREGNANT=1") }) private Set<Human> members = new HashSet<Human>(); This is excerpted from here: https://github.com/rworsnop/hibernate-orm/blob/HHH-2394/hibernate-core/src/matrix/java/org/hibernate/test/annotations/filter/subclass/joined/Club.java Thoughts? _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev