Reputation: 21496
I have an entity mapped with a @Where
annotation like:
@Where(clause = "is_active = 1")
That works fine, but now I want to write a query that doesn't use the annotated filter condition in the where
clause.
The only way I can think of is to fall back to a native query.
Is there a way to disable a filter for a single specific query?
I'm using a JpaRepository
@Query
annotated interface method to declare my query like:
@Query(name = "UnmergeStudent", value = "select .... student_1.lui = :lui")
List<UnmergeStudentSummary> findMergedStudentSummaryByLui(@Param("lui") String lui);
I looked at the members of the @Query
annotation but can't see anything obvious. Is there a way to avoid filters if I fall back to writing the actual query code in a normal method?
Hibernate version is 5.2.10.Final
Upvotes: 1
Views: 1294
Reputation: 36203
You cannot disable @Where
but you could use @Filter
instead.
The difference between @Where
and @Filter
is that @Filter
can be parameterized and @Filter
has a name and must be turned on using that name:
entityManager
.unwrap(Session.class)
.enableFilter("your_filter");
Read more about this in the offical documentation:
Upvotes: 1