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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With