-->
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.  [ 2 posts ] 
Author Message
 Post subject: Build Criteria Dinamically
PostPosted: Fri Apr 21, 2006 2:47 pm 
Newbie

Joined: Wed Dec 14, 2005 7:27 am
Posts: 18
Is it possible to build Criteria queries dinamically, like an SQL query?

For example, i've this query

SELECT name FROM table1 where 1=1 and name = Tom and program=JBOss and address = Lisbon, etc ...,

and i want to build a criteria query, but i don't know how many conditions i would have in the Criteria.

How i do this?


Thanks,
Pedro


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 4:59 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
thats what the Criteria stuff was made for. Just string some if statements or some loops and you can keep adding stuff to your query depending on the need

Code:
Critera crit = new Criteria(some.class);

if (checkSomethingHere)
    crit.addCondition;

if (checkSomethingElse)
    crit.addCondition;


_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.