Example usage for org.hibernate Query setString

List of usage examples for org.hibernate Query setString

Introduction

In this page you can find the example usage for org.hibernate Query setString.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setString(String name, String val) 

Source Link

Document

Bind a named String-valued parameter.

Usage

From source file:com.appeligo.search.entity.User.java

License:Apache License

/**
 * /*from  w ww . j a v  a 2s .  com*/
 * @param username
 * @return
 */
@SuppressWarnings("unchecked")
public static User findByUsername(String username) {
    Session session = getSession();
    Query query = session.getNamedQuery("User.findByUsername");
    query.setString("username", username);
    List<User> users = query.list();
    if (users.size() > 0) {
        return users.get(0);
    } else {
        return null;
    }
}

From source file:com.appeligo.search.entity.User.java

License:Apache License

private static User findByQuery(String queryName, String paramName, String param) {
    Session session = getSession();/*w w  w.  j a v  a 2s . co m*/
    Query query = session.getNamedQuery(queryName);
    query.setString(paramName, param);
    List<User> users = query.list();
    if (users.size() > 0) {
        return users.get(0);
    } else {
        return null;
    }
}

From source file:com.appeligo.search.entity.User.java

License:Apache License

public boolean isEmailAvailableForUser(String email) {
    Session session = getSession();/*from  w  w  w.ja  va2s.  c o  m*/
    Query query = session.getNamedQuery("User.checkEmailAvailableForUser");
    query.setString("email", email);
    query.setEntity("user", this);
    List test = query.list();
    if (test.size() > 0) {
        return false;
    } else {
        return true;
    }
}

From source file:com.appeligo.search.entity.User.java

License:Apache License

/**
 * //  w  ww . ja  va2  s  . c o m
 * @param username
 * @return
 */
@SuppressWarnings("unchecked")
public static User findByUsernameAndSecret(String username, String registrationSecret) {
    Session session = getSession();
    Query query = session.getNamedQuery("User.findByUsernameAndRegistrationSecret");
    query.setString("username", username);
    query.setString("registrationSecret", registrationSecret);
    if (log.isInfoEnabled()) {
        log.info("Attempting to load user by " + username + " and " + registrationSecret);
    }
    User user = (User) query.uniqueResult();
    return user;
}

From source file:com.aprotrain.sl.dal.dao.impl.EmployeeServiceImpl.java

public Employee checkLogin(String internalEmail, String password) {
    Session session = this.getSession();

    Query query = session.createQuery("FROM Employee WHERE internalEmail=:mail AND password=:password");
    query.setString("mail", internalEmail);
    query.setString("password", password);
    query.setMaxResults(1);//from w w  w.  ja v a2s  . c o  m

    List<Employee> list = query.list();
    Employee e = null;
    if (!list.isEmpty()) {
        e = list.get(0);
    }

    session.close();

    return e;
}

From source file:com.asha.tow.dao.impl.UserDaoImpl.java

@Override
public User login(String username, String password) {
    Query query = getSession()
            .createSQLQuery("select * from User where username=:username and password=:password");
    query.setProperties(User.class);
    query.setString("username", username);
    query.setString("password", password);
    List list = query.list();//ww w.java 2 s  . c o  m
    User user = null;
    for (Iterator it = list.iterator(); it.hasNext();) {
        User u = (User) it.next();
        user = new User(u.getUsername(), u.getEmail(), u.getPassword(), u.getLastlog());
    }
    return user;

}

From source file:com.asha.tow.dao.impl.UserDaoImpl.java

@Override
public boolean checklogins(String username, String password) {
    boolean userFound = false;
    Query query = getSession()
            .createSQLQuery("select * from User where username=:username and password=:password");
    query.setString("username", username);
    query.setString("password", password);
    List list = query.list();/* w ww . j  a  v a2s .c  om*/
    if ((list != null) && (list.size() > 0)) {
        userFound = true;
    }
    return userFound;
}

From source file:com.bank.springmvc.dao.KlijentDaoImpl.java

public void deleteClientById(int klijent_id) {
    Query query = getSession().createSQLQuery("delete from Klijent where jmbg = :jmbg");
    query.setString("klijent_id", String.valueOf(klijent_id));
    query.executeUpdate();/*from w ww. j av a  2 s. c  o m*/
}

From source file:com.bloatit.data.DaoDescription.java

License:Open Source License

/**
 * Get a translation for a given locale.
 * /* www.java  2s .c  o  m*/
 * @param locale the locale in which we want the description
 * @return null if no translation exists for this locale.
 */
public DaoTranslation getTranslation(final Language language) {
    final Query q = SessionManager.getNamedQuery("description.getTranslations.byLocale");
    q.setString("locale", language.getCode());
    q.setEntity("this", this);
    return (DaoTranslation) q.uniqueResult();
}

From source file:com.bloatit.data.DaoMember.java

License:Open Source License

/**
 * Finds a DaoMember using its email.//from www. ja v  a 2  s . c  o  m
 *
 * @param email the email of the member
 * @return the member matching <code>email</code> or <i>null</i> if not
 *         found
 */
public static DaoMember getByEmail(final String email) {
    if (email == null) {
        return null;
    }

    final Query q = SessionManager.getNamedQuery("member.byEmail");
    q.setString("email", email);
    return (DaoMember) q.uniqueResult();

}