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.EmpInfo;
import roseindia.model.StudentModel;

public class CriteriaDAO {

	@SuppressWarnings("deprecation")
	public List<StudentModel> resultData(StudentModel obModel) {
		SessionFactory sessionFactory = new AnnotationConfiguration()
				.configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		Criteria criteria = session.createCriteria(EmpInfo.class);
		criteria.add(Restrictions.or(Restrictions.eq("fname", obModel.getFname()), Restrictions.eq("id", obModel.getId())));
		List<StudentModel> studentList = criteria.list();
		Iterator studentIterator = studentList.iterator();
		return studentList;
	}
}
