Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Criteria in hibernate is incasesensitive?

Tags:

java

hibernate

I am using criteria api to check If the user name exists or not. After that I am checking the password. But the user name is not case sensitive. I want to make it case sensitive.

Criteria criteria2 = session.createCriteria(UserMaster.class);
criteria2.add(Restrictions.eq("userName", userName));
userDetails = (UserMaster)criteria2.uniqueResult();
if(userDetails != null) {
      //logic goes here
 }

Any help will be appreciated.

like image 506
Sunil Kumar Naik Avatar asked May 19 '15 09:05

Sunil Kumar Naik


1 Answers

How strings are compared, depends on the brand and version of the database and the settings of the database. Some databases, for example Microsoft SQL Server, compare strings in a case-insensitive way by default, while others compare strings in a case-sensitive way.

Check the settings of your database; lookup the documentation of your particular brand and version of database to find out how to change this setting.

If it is indeed MS SQL Server, then look for example at this question: Sql Server check case sensitivity?

like image 196
Jesper Avatar answered Sep 30 '22 13:09

Jesper