how to check username and password in hibernate criteria with case sensitive

asked 2017-02-06 13:38:02 +0800

Manihtraa gravatar image Manihtraa
3 1

I'm having simple login page username is "Admin" and password is "hello" but criteria function is accept all values like "HELlo" "HELLO" this types. i want to only accept case sensitive result. what can i do....

public RoomMembers logIn(Members members) {
    Criteria criteria = sessionFactory
    criteria.add(Expression.eq("memberUserName", members.getMemberUserName()));
    criteria.add(Expression.eq("password", members.getPassword()));

    Members Member=(Members) criteria.uniqueResult();
    return Member;
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-07 07:19:32 +0800

chillworld gravatar image chillworld flag of Belgium
5257 3 9

updated 2017-02-07 07:26:46 +0800

Are you sure? Normally you need to do this for case insensitive :

criteria.add(Expression.eq("password", members.getPassword()).ignoreCase());

Check the real value what you put in the query, maybe you already converted the value to all uppercase or lowercase.


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2017-02-06 13:38:02 +0800

Seen: 25 times

Last updated: Feb 07 '17