Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
hibernateTemplate-Order Results 
 

In this section you will learn how to add ordering ability to in Hibernate Application when using hibernateTemplate.

 

hibernateTemplate-Order Results

                         

In this section you will learn how to add ordering ability to in Hibernate Application when using hibernateTemplate. There are many ways you can order your results when using hibernateTemplate.

Suppose you have a class called "Student" with the fields "studentName", "StudentCode" and you want to retrieve all the records from database in sorted by "studentName" in ascending order. There are following options for you.

  1. Use getHibernateTemplate().find() method
    Following code shows how you can use getHibernateTemplate().find() method:
    public Collection loadAllStudent() throws DataAccessException{
       
    return getHibernateTemplate().find("from Student student order by student.studentName");
    }
     
  2. Use getHibernateTemplate().findByCriteria()
    Following code shows how you can use getHibernateTemplate().findByCriteria() function in your hibernate application.
    public Collection loadAllStudent() throws DataAccessException{
       return getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(
    Student.class).addOrder(Order.asc("studentName")));
    }
     

                         

» View all related tutorials
Related Tags: c hibernate application template io order using this ordering app add nat to learn ear bi e il it section

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.