I am using the FilterDef and Filter annotations in order to use a parameterized filter that I set at runtime.
This gets executed correctly when I do a query using the entityManager create query methods, but when I use the entityManager.find, the filter is not added to the query.
Using the '@Where' annotation does add the clause but this annotation can't be parameterized as far as I know.
My environment is jBoss EAP 7 that uses hibernate 5.0.9
jBoss EAP 7 using Hibernate 5.0.9
This works as designed. Please see the documentation in section:
See the box starting, "Filters apply to entity queries, but not to direct fetching"
Would you know what was the rationale behind the design decision you are referring to? Could you provide a link to a relevant discussion?
, discussions happen in many places; there is likely a discussion on jira issues where filters were first implemented, or possibly the hibernate-dev mailing list or freenode chatroom.