-->
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: NEED help on how to dynamically set data
PostPosted: Fri Sep 26, 2008 7:16 pm 
Newbie

Joined: Fri Sep 26, 2008 6:54 pm
Posts: 1
I need to build a native sql query which has bunch of OR in the query
and add data dynamcally by looping thru ( 10 times)

for ( int i =0; i< data.size();i++){

Query.setParameter("no",No);
Query.setParameter("cd",Cd);

}


List lst = Query.list()

sample query:


select * from temp where( ( no = ? and cd = ? )or ( no = ? and cd = ? a )
or ( no = ? and cd = ? )
.....)

i have to replace ? with te data

Please help me on this

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2008 2:41 am 
Beginner
Beginner

Joined: Wed Sep 24, 2008 5:44 pm
Posts: 34
You coullddd....

Code:
Criteria c = new Criteria(Temp.class);

for (Object o : data) {
    c.add(Expression.or(Expression.eq("no", o.no), Expression.eq("cd" o.cd)));
}

List<Temp> = c.list();


yes?


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.