Scalar results in Hibernate by R4R Team

Queries can specify a property of a class in the select clause. Here we can can even call SQL aggregate functions. Properties or aggregates are considered "scalar" results and not entities in persistent state.

Iterator results = session.createQuery( "select student.color, min(student.birthdate), count(student) from Student student " +
        "group by student.color")
        .list()
        .iterator();

while ( results.hasNext() ) 
{
    Object[] row = (Object[]) results.next();
    Color type = (Color) row[0];
    Date oldest = (Date) row[1];
    Integer count = (Integer) row[2];
    .....
}
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!