Hibernate criteria for date.
Posted on: April 7, 2011 at 12:00 AM
Hibernate criteria for date.

Hibernate criteria for date.

In this example, you will see how to create criteria for date. This example will access record from data, that is  greater then or equal to given date. It is like as search by data.


package roseindia.hibernateDAO;

import java.util.Iterator;

import java.util.List;

import org.hibernate.criterion.*;

import org.hibernate.Criteria;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.cfg.AnnotationConfiguration;

import roseindia.model.StudentModel;

public class CriteriaDAO {


public List<StudentModel> resultData(StudentModel obModel) {

SessionFactory sessionFactory = new AnnotationConfiguration()


Session session = sessionFactory.openSession();

Criteria criteria = session.createCriteria(StudentModel.class).add(

Expression.ge("date", obModel.getDate()));

List<StudentModel> studentList = criteria.list();

Iterator studentIterator = studentList.iterator();

return studentList; } }

Download Source Code

Related Tags for Hibernate criteria for date.: