The goal is to do a LogIn through an HQL, I'm currently at this point in the code:
public boolean LogIn(String nickname, String password){
boolean inAnswer = false;
try{
inAnswer = true;
this.session = Hibernate.getSessionFactory().getCurrentSession();
Query login = session.createQuery ("From Usuario usser "
+ "where usser.Nickname ='"+nickname+"' & usser.Password ='"+password+"'");
}catch (Exception e){
e.printStackTrace();
}
return inAnswer;
}
My question is, can I implement an if/switch inside that try that does a comparison of the nickname and password variables with the login object? Something like:
if(login.equals(String nickname, String password))
If the variable
Query login
you are using (it will depend on where you import it from) allows you to retrieve the values, you will be able to do what you ask.On the other hand, it can always be programmed within the
try{} catch(){}
addition that allows you to encapsulate/control the errors that may appear during the execution of the code.Here the answer to your question: