CriteriaEager.java
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.FetchMode; import org.hibernate.Session; public class CriteriaEager { public static void main(String[] args) { Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Student.class); criteria.setFetchMode("name", FetchMode.EAGER); List list = criteria.list(); Iterator iterator = list.iterator(); while (iterator.hasNext()) { Student student = (Student) iterator.next(); System.out.println(student.getName()); } } }
Hibernate: select this_.roll_no as roll1_0_,
this_.name as name0_0_, this_.course as course0_0_, this_.address as
address0_0_, this_.addmision_date as addmision5_0_0_ from student this_ Ramesh Raman Aman Raman Vikash Ramesh Bharat Chulbul Panday |
Advertisements
Ads
Ads