Home Hibernate Examples Criteria Hibernate Criteria Max Date

Ask Questions?

View Latest Questions


Hibernate Criteria Max Date
Posted on: April 13, 2011 at 12:00 AM
In this tutorial you will learn Hibernate Criteria Max Date

Hibernate Criteria Max Date

An example of getting Max Date from the Hibernate Criteria is given below


package net.roseindia.main;

import java.util.Iterator;
import java.util.List;

import net.roseindia.bean.Student;
import net.roseindia.util.HibernateUtil;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;

public class CriteriaMaxDate {
	public static void main(String[] args) {
		Session session = HibernateUtil.getSessionFactory().openSession();
		Criteria criteria = session.createCriteria(Student.class);
		ProjectionList projectionList = Projections.projectionList();
		List list = criteria.list();
		Iterator iterator = list.iterator();

When you run this application it will display message as shown below:

ibernate: select max(this_.addmision_date) as y0_ from student this_
2007-07-19 00:00:00.0

Download Complete Source Code

Related Tags for Hibernate Criteria Max Date: