Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Object Relational Mapping
How to put List in hibernate Query
shyam sunder prasad
Ranch Hand
Posts: 62
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thanks for reading my question,
i have a method ,
public List getTotalStudents(List studentsIdsList){ Session s=HibernateUtil.getSession(); Transaction tx=s.beginTransaction(); Query q=session.createQuery("from student "); // (1) return q.list(); } so, i want to fetch data from database based on id s in the studentsIdsList; studentsIdsList is contains all ids of students, without using any for loop to retrieve ids from the List ,how to put List itself in the query or criteria. please help me out how to put studentsIdsList in where condition of query at a time.
shyam sunder prasad
Ranch Hand
Posts: 62
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Alex Armenteros
Ranch Hand
Posts: 75
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
well using Criteria is very easy
//be careful you don't use org.hibernate.classic.Session Session ses=dao.getSession(); Criteria cr=ses.createCriteria(tableMappingClass.class); //The list must be a list of objects of the same type that the field you want to filter has. cr.add(Restrictions.in("field",list); List ls=cr.list();
hope this helps.
shyam sunder prasad
Ranch Hand
Posts: 62
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
thank you very much Armenteros
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to put Nested conditions in sql query
drop down menu usinng optionCollections
random resultsets
Hibernate query help
How to write a Crieteria for
More...