The Case Insensitive ignores the case of the latter. It Selects all the records of the table related to the given parameters
Criteria criteria = session.createCriteria(Student.class); criteria.add(Restrictions.eq("name", "ramesh").ignoreCase()); List list = criteria.list();
CriteriaCaseInSensitive.java
package net.roseindia.main; import net.roseindia.bean.Student; import net.roseindia.util.HibernateUtil; import org.hibernate.Criteria; import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.criterion.Restrictions; import java.util.*; public class CriteriaCaseInSensitive { public static void main(String[] args) { try { Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Student.class); criteria.add(Restrictions.eq("name", "ramesh").ignoreCase()); List list = criteria.list(); Iterator listIterator = list.iterator(); while (listIterator.hasNext()) { Student student = (Student) listIterator.next(); System.out.println(student.getName()); } } catch (HibernateException e) { e.printStackTrace(); } } }
Hibernate: select this_.roll_no as roll1_0_0_,
this_.name as name0_0_, this_.course as course0_0_, this_.address as
address0_0_ from student this_ where lower(this_.name)=? Ramesh Ramesh |
Advertisements
Ads
Ads