@Override
    public UserDTO getUserByLogin(String login, String pass) throws SQLException {
        Session session = null;
        UserDTO user = null;
        try {
            session = HibernateUtil.getSessionFactory().openSession();
            user = (UserDTO) session.createCriteria(UserDTO.class)
                    .add(Restrictions.and(
                            Restrictions.like("login", login),
                            Restrictions.like("pass", pass)
                    ))
                    .setMaxResults(1).uniqueResult();
        } catch (Exception e) {
            System.err.println("Error while getting user by login and password!");
        } finally {
            if (session != null && session.isOpen()) {
                session.close();
            }
        }
        return user;
    }