Saturday, 23 March 2013

Or in Hibernate Criteria

public String LoginUser(String email, String password) {

  Criteria criteria = session.createCriteria(User.class); // Pass Your Bean Name
  Criterion criterion1 = Restrictions.eq("email", email);
  Criterion criterion2 = Restrictions.eq("phone", email); // email or phone name of field define in Bean Class

  criteria.add(Restrictions.eq("password", password));
  if (criteria.list().size() > 0) 
      return SUCCESS;
  else
       return ERROR;

 }