简体   繁体   中英

Hibernate @Filter annotation usage

Currently I am using Hibernate 3.2 @Filter feature along with JPA so everything goes through entity manager. My question this use case:

Suppose we have annotated entity class A with @Filter(name="filterOne") Now suppose that entity class A is a composition of entity class B

B <>---- listOfA - List::A ---- A (fetch type is eager)

Now B.listOfA (attribute) is annotated with @Filter(name="filterTwo")

Will hibernate apply filterOne and filterTwo if I query for entity B and get listOfA ?

No, the filters are not applied to to-many associations if they are defined at the target entity level only and, by the way, they are never applied on to-one associations.

You have to explicitly define the filter at the collection level as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM