Example usage for org.hibernate StatelessSession createCriteria

List of usage examples for org.hibernate StatelessSession createCriteria

Introduction

In this page you can find the example usage for org.hibernate StatelessSession createCriteria.

Prototype

@Deprecated
Criteria createCriteria(Class persistentClass);

Source Link

Document

Create Criteria instance for the given class (entity or subclasses/implementors).

Usage

From source file:vault.queryrouter.models.dao.UserDAO.java

License:Apache License

public static String getPassword(StatelessSession session, String userName, int tenantMppdbId) {
    Iterator users;//ww w. j  av a2  s .  c o m
    String password = null;
    try {
        Criteria criteria = session.createCriteria(User.class);
        criteria.add(Expression.eq("userName", userName));
        criteria.add(Expression.eq("tenantMppdbId", tenantMppdbId));
        users = criteria.list().iterator();
        while (users.hasNext()) {
            User user = (User) users.next();
            password = user.getPassword();
        }
    } catch (Exception e) {
        logger.error("Fail to get password", e);
        throw e;
    }
    return password;
}