I have this method that checks the username and password of a user before login. Now my for loop checks only the first item, it finds that the first condition, u.getRole()
As has been pointed in the comments, you have only two alternatives in the loop, both make the loop to finish (on return
or on break
) Just take off the break;
statement or change it for a continue;
.
By the way, why don't you select from User where role = 'recruiter'
only? This will make the roundtrip to the database server not to return all users, but only the ones that you are interested in.