aspose 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 Spring in Action this week in the Spring 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: 93
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