Hibernate Annotations 3.4.0.GA
Hibernate 3.3.1.GA
Hibernate Commons Annotations 3.1.0.GA
Is it possible to override a Where Clause Annotation?
By default I want only products to be visible that have the property visible=true, so that I don't have to put that condition at every query.
But in a few cases I want also to be able to query for visible=false.
Is it possible to let Hibernate override that when visible=true is set in a @Where clause annotation? (see below)
I tried this:
Code:
@Entity
@Where(clause="visible = 0") // 0 is equal to true; its a bit
class Product {
......
private Boolean visible;
....
}
When I now perform a query like:
session.createQuery("from Product where visible = true");
It will give a contradiction :
Code:
select
product0_.id as id1_,
......
from
Product product0_
where
(
product0_.notVisible != 1
)
and product0_.notVisible=1
Is it possible to let Hibernate override the Where annotation visible=true in a query?