I try to do a case sensitive equals on username
with Hibernate (3.6.9) but it seems that the restriction is case insensitive.
For example: "AdMin" or "admin" is both valid but only "admin" should be correct and otherwise .size()
should return 0. I would try to avoid using like
. Somebody got a different solution?
Code:
Session sess = getSessionFactory().getCurrentSession();
@SuppressWarnings("unchecked")
List<Login> logins = sess.createCriteria(Login.class).add(Restrictions.idEq(username)).list();
if(logins.size() == 1) {
return logins.get(0);
} else {
return null;
}
Microsoft SQL Server and MySQL doesn't make a difference in this case.