-->
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: Criteria question
PostPosted: Tue Jul 08, 2008 5:54 am 
Newbie

Joined: Wed May 02, 2007 6:37 am
Posts: 6
Hi All,

I am relatively new to hibernate and having a few problems with implementing criteria.

I want a query smiliar to: FROM T1 WHERE (x=1 and x2=1) OR (y=1 and y2=1).



Code:
List test = session.createCriteria(T1.class)
            
            .add(Expression.and(
            Expression.eq("", x),
             Expression.eq("", x2
            ))
            .add(Expression.or(
             Expression.eq("", y),
             Expression.eq("", y2)
             )).list();

This generates the query: FROM T1 WHERE (x=1 and x2=1) AND (y=1 and y2=1).

How can i change the code to expression the OR statement?

Thanks


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.