-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Override Where Clause annotation in query
PostPosted: Sat Oct 11, 2008 10:39 pm 
Newbie

Joined: Tue Dec 18, 2007 7:42 am
Posts: 19
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.