5

I'm using Hibernate version 4.3.5.Final. The problem here is that Hibernate finds entities of the type Foo where the case of the property address has different a case (e.g. "BLAFOO"). However, in my example, ex.ignoreCase() is not called.

I only want to find entities which match the exact case. What am i doing wrong?

Foo myBean = new Foo();
myBean.setAddress("blaFoo");
Example ex = Example.create(myBean);
ex.excludeZeroes();
//ex.ignoreCase();
DetachedCriteria crit = DetachedCriteria.forClass(Foo.class).add(ex);   
List<MonitoredApp> apps = dao.findByDetachedCriteria(crit);
Tarator
  • 1,517
  • 1
  • 13
  • 30
  • 1
    Using MySQL? Read http://dev.mysql.com/doc/refman/5.7/en/case-sensitivity.html. – JB Nizet Jun 17 '14 at 19:38
  • 1
    possible duplicate of [Case sensitive Search in Hibernate Criteria](http://stackoverflow.com/questions/11030921/case-sensitive-search-in-hibernate-criteria) – durron597 Jun 17 '14 at 19:59
  • 1
    Ultimately it depends on filed collation of db - if it's '_ci' (case-insensitive) or '_cs' (case-sensitive) – CrashOverload Jul 10 '14 at 05:57

1 Answers1

1

This is probably caused by a case insensitive comparison at the database itself.

Check the character set/collation of your table/database.

Jimmy T.
  • 4,033
  • 2
  • 22
  • 38