File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes how to retrieve data from associated table in ascenting order using crietria Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "how to retrieve data from associated table in ascenting order using crietria" Watch "how to retrieve data from associated table in ascenting order using crietria" New topic
Author

how to retrieve data from associated table in ascenting order using crietria

john sal
Ranch Hand

Joined: Jul 30, 2010
Posts: 92
I have two bean classes..



Now I want to retrieve the Subject for a particular student in ascending order using creitria query. For doing the same first I have to retrieve the student object from the database, now i want that after getting the student object if I perform student.getSubjects() I get the list of all the subjects that has been taken by the particular statment in ascending order of subject name.

Can somebody let me know how to write a creitria query for the same.

Thanks
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
To order a OneToMany use the @OrderBy annotation.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Ordering

You cannot change an objects relationships based on a query.

You could query for the Subjects for a Student direct and order it however you wish in the query.


TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to retrieve data from associated table in ascenting order using crietria
 
Similar Threads
Not able to get mapped object Set in hibernate
Hibernate: Updates all the items of a set - Cascade ‘create’ not working
Retrieving count of Y and count of N from a single column in a table
Class concept Explanation
java code and SAX