I'm trying to make a Login app with JSF, and I found in forums that a lot of people use LoginByUsername(or findByUsername or whatever they call it ,anyway a method that does find the username and returns the user and uses SQL) and they put it in the facade(session bean for entity class) !
But the facade itself gives us something called find(Object id) ,and the id is username .
so what's better : using find or making its own method(that uses SQL)? and why?
thanks in advance for your help
If the
usernameis used asidin your app, then it's no need to write a new methodLoginByUsername/findByUsername, since you have already have the methodfind(Object id), which can achieve the functionfindByUsernamewill do.But, since it's a Login App, i think it's better to provide a method called
findByUserAndPassword, and if no result is returned, tell the user that user or password is wrong, which it's commonly used in many website.