# Hibernate @Filter can only filter table fields. What should I use to filter on entity properties, and not table columns?

**URL:** <https://discourse.hibernate.org/t/hibernate-filter-can-only-filter-table-fields-what-should-i-use-to-filter-on-entity-properties-and-not-table-columns/2382>\
**Category:** Hibernate ORM\
**Created:** [February 27, 2019, 9:17am UTC](https://discourse.hibernate.org/t/hibernate-filter-can-only-filter-table-fields-what-should-i-use-to-filter-on-entity-properties-and-not-table-columns/2382 "2019-02-27T09:17:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Left4\_Dead](https://avatars.discourse-cdn.com/v4/letter/l/a88e57/32.png) [@Left4\_Dead](https://discourse.hibernate.org/u/Left4_Dead)\
**Post date:** [February 27, 2019, 9:17am UTC](https://discourse.hibernate.org/t/hibernate-filter-can-only-filter-table-fields-what-should-i-use-to-filter-on-entity-properties-and-not-table-columns/2382/1 "2019-02-27T09:17:39Z")

</div>

I want to create a filter that can filter my queries based on Entity Objects and not Table Fields. For example, I have Entity1 that has a ManyToMany relation to Entity2

Which is

`Set<Entity2>`

I want to create a filter which is gonna give me a list of Entities1 where its own

`Set<Entity2>`

will contain only those Entity2 records as I passed there in the

`parameters.filter.setParameterList("paramName",Set<Entity2>`

I can’t achieve the result I need with @Filter because it’s using SQL that won’t let me compare such thing as

`where (1,2) in (1,2,3)`

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [February 27, 2019, 2:25pm UTC](https://discourse.hibernate.org/t/hibernate-filter-can-only-filter-table-fields-what-should-i-use-to-filter-on-entity-properties-and-not-table-columns/2382/2 "2019-02-27T14:25:01Z")

</div>

The best way to filter an entity is to use a query, not a `@Filter` or a `@Where` clause.

So, in your case, you are better off using a JPQL, Criteria API or [native SQL query](https://vladmihalcea.com/fix-hibernate-hhh000104-entity-fetch-pagination-warning-message/).
