Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate case sensitive comparison

 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!!

I tried:
- Restrictions.eq("field", value)
- Restrictions.like("field", value)
- Restrictions.ilike("field", value)

But all of the above are case insensitive.
The stored value is abc. If I enter Abc it returns true.

How can I make a case sensitive search?

The entire code that I'm using is below:
 
Fadjer One
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

You can use Criteria API instead. For example you can use the class : org.hibernate.criterion.Example

Please check this link :
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html

 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fadjer One wrote:Hello,

You can use Criteria API instead. For example you can use the class : org.hibernate.criterion.Example

Please check this link :
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querycriteria.html


Thank you!
The problem was with MySQL. The column needs to be "binary", otherwise the comparison is case insensitive.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic