The Hibernate Criteria Lower Ignore a the case. You can use ilike() method or ignoreCase() method as
criteria.add(Restrictions.ilike("name", "%v%"));
Or
criteria.add(Restrictions.eq("name", "vikash").ignoreCase());
Both can be usedADS_TO_REPLACE_1
An example is given below, please consider
LowerCase.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.Session; import org.hibernate.criterion.Restrictions; public class LowerCase { public static void main(String[] args) { Session session = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = session.createCriteria(Student.class); criteria.add(Restrictions.ilike("name", "%v%")); List results = criteria.list(); Iterator iterator = results.iterator(); while (iterator.hasNext()) { Student student = (Student) iterator.next(); System.out.println(student.getName()); } } }
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) like ? Vikash |
Download Complete Source CodeADS_TO_REPLACE_2
Advertisements
Ads
Ads