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:br.com.hslife.clickafacil.dao.InfoAdicionaisDao.java

License:Open Source License

public boolean emailExiste(String email) throws Exception {
    String hql = "from InfoAdicionais where email = :email";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("email", email);
    // Retorna true se nenhum outro e-mail foi localizado
    if (q.list().size() == 0) {
        return true;
    } else {/*w  w  w  . j  a  va 2s .c  o  m*/
        return false;
    }

}

From source file:br.com.hslife.clickafacil.dao.InfoAdicionaisDao.java

License:Open Source License

public InfoAdicionais buscarEmail(String email) throws Exception {
    String hql = "from InfoAdicionais where email = :email";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("email", email);
    return (InfoAdicionais) q.list().get(0);

}

From source file:br.com.hslife.clickafacil.dao.InternautaDao.java

License:Open Source License

public Internauta buscarPorEmail(String id) throws Exception {
    String hql = "from Internauta where email = :email";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("email", id);
    return (Internauta) q.list().get(0);
}

From source file:br.com.hslife.clickafacil.dao.InternautaDao.java

License:Open Source License

public List listarPorNome(String nome) throws Exception {
    String hql = "from Internauta where nome like concat('%', :nome, '%') order by nome";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("nome", nome);
    return q.list();
}

From source file:br.com.hslife.clickafacil.dao.InternautaDao.java

License:Open Source License

public boolean cpfExiste(String numero) throws Exception {
    String hql = "from Internauta where cpf = :numero";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("numero", numero);
    if (q.list().size() == 0) {
        return false;
    } else {//from   www.ja  v a2s.co m
        return true;
    }
}

From source file:br.com.hslife.clickafacil.dao.InternautaDao.java

License:Open Source License

public boolean verificaEmail(String email) throws Exception {
    String hql = "from Internauta where email = :email";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("email", email);
    // Retorna true se nenhum outro e-mail foi localizado
    if (q.list().size() == 0) {
        return true;
    } else {/* ww w .  ja va 2  s  . c  o m*/
        return false;
    }
}

From source file:br.com.hslife.clickafacil.dao.ProdutoDao.java

License:Open Source License

public List listarPorNome(String nome) throws Exception {
    String hql = "from Produto where nomeProduto like concat('%', :nomeProduto, '%') order by nomeProduto";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("nomeProduto", nome);
    return q.list();
}

From source file:br.com.hslife.clickafacil.dao.ProdutoDao.java

License:Open Source License

public List buscarPorNomeProduto(String nome) throws Exception {
    String hql = "from Produto where nomeProduto like :nome";
    Query q = HibernateUtil.getInstance().createQuery(hql);
    q.setString("nome", nome);
    return q.list();
}

From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java

License:Open Source License

public List queryList(String namedQuery, Map<String, Object> params) {
    HibernateUtility.getSession().clear();
    Query query = HibernateUtility.getSession().getNamedQuery(namedQuery);
    for (String key : params.keySet()) {
        if (params.get(key) instanceof String) {
            query.setString(key, (String) params.get(key));
        }//from  w  ww  .  ja  v  a2 s .  c  o m
        if (params.get(key) instanceof Long) {
            query.setLong(key, (Long) params.get(key));
        }
        if (params.get(key) instanceof Integer) {
            query.setInteger(key, (Integer) params.get(key));
        }
        if (params.get(key) instanceof Boolean) {
            query.setBoolean(key, (Boolean) params.get(key));
        }
        if (params.get(key) instanceof Double) {
            query.setDouble(key, (Double) params.get(key));
        }
        if (params.get(key) instanceof Date) {
            query.setDate(key, (Date) params.get(key));
        }
    }
    return query.list();
}

From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java

License:Open Source License

public void queryNoResult(String namedQuery, Map<String, Object> params) {
    Query query = HibernateUtility.getSession().getNamedQuery(namedQuery);
    for (String key : params.keySet()) {
        if (params.get(key) instanceof String) {
            query.setString(key, (String) params.get(key));
        }/*from  w w  w  .  ja  v a  2  s.  c om*/
        if (params.get(key) instanceof Long) {
            query.setLong(key, (Long) params.get(key));
        }
        if (params.get(key) instanceof Integer) {
            query.setInteger(key, (Integer) params.get(key));
        }
        if (params.get(key) instanceof Boolean) {
            query.setBoolean(key, (Boolean) params.get(key));
        }
        if (params.get(key) instanceof Double) {
            query.setDouble(key, (Double) params.get(key));
        }
        if (params.get(key) instanceof Date) {
            query.setDate(key, (Date) params.get(key));
        }
    }
    query.executeUpdate();
    HibernateUtility.getSession().flush();
    HibernateUtility.getSession().clear();
}