List of usage examples for org.hibernate Query setParameter
@SuppressWarnings("unchecked") Query<R> setParameter(int position, Object val);
From source file:br.com.proj.tasker.dao.impl.TarefaDAO.java
@Override public List<Tarefa> buscaTarProjCargo(Integer id, Integer id2) { Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery( "Select tar from Tarefa as tar JOIN tar.projeto as pro WHERE pro.idProj = :id AND tar.status<>'Desativada' AND tar.status<>'Finalizada' AND tar.cargo.idCargo = :id2"); query.setParameter("id", id); query.setParameter("id2", id2); List<Tarefa> tars = query.list(); session.close();/*from w w w .ja va2s .co m*/ return tars; }
From source file:br.com.sescacre.controleAcesso.dao.CargosDoSetorDAO.java
public List<CargosDoSetor> pesquisaCargosDoSetorPorSetor(Integer id) {//join Session s = HibernateUtil.getSession(); Query q = s.createQuery("from CargosDoSetor cds where cds.setor.id = :setor order by cds.cargo.nome"); q.setParameter("setor", id); List<CargosDoSetor> lista = q.list(); s.close();/* w w w .jav a2 s . c o m*/ return lista; }
From source file:br.com.sescacre.controleAcesso.dao.CargosDoSetorDAO.java
public List<CargosDoSetor> pesquisaCargosDoSetorPorCargo(Integer id) {//join Session s = HibernateUtil.getSession(); Query q = s.createQuery("from CargosDoSetor cds where cds.cargo.id = :cargo order by cds.id"); q.setParameter("cargo", id); List<CargosDoSetor> lista = q.list(); s.close();//w w w . j a v a 2 s . com return lista; }
From source file:br.com.sescacre.controleAcesso.dao.FuncionariosDao.java
public Funcionarios pesquisaPorMat(Integer mat) { Session s = HibernateUtil.getSession(); Query q = s.createQuery("from Funcionarios f where f.matricula = :mat"); q.setParameter("mat", mat); return (Funcionarios) q.uniqueResult(); }
From source file:br.com.sescacre.controleAcesso.dao.FuncionariosDao.java
public List<Funcionarios> pesquisaFuncionarioPorCargoDoSetor(Integer id) {//join Session s = HibernateUtil.getSession(); Query q = s.createQuery("from Funcionarios f where f.cargo.id = :cargo order by f.id"); q.setParameter("cargo", id); List<Funcionarios> lista = q.list(); s.close();/*www. jav a 2s. com*/ return lista; }
From source file:br.com.sescacre.dao.AlunosDAO.java
public Alunos pesquisaAlunoPorCPF(String cpf) { Session s = HibernateUtil.getSession(); Query q = s.createQuery("from Alunos a where a.cpf = :cpf order by a.nome"); q.setParameter("cpf", cpf); Alunos a = (Alunos) q.uniqueResult(); s.close();/*from w w w . j av a2s . c o m*/ return a; }
From source file:br.com.sescacre.dao.CargosDoSetorDAO.java
public List<CargosDoSetor> pesquisaCargosDoSetorPorSetor(Integer id) {//join Session s = HibernateUtil.getSession(); Query q = s.createQuery("from CargosDoSetor cds where cds.setor.id = :setor order by cds.id"); q.setParameter("setor", id); List<CargosDoSetor> lista = q.list(); s.close();/*from w w w .j a va 2 s . co m*/ return lista; }
From source file:br.com.sescacre.dao.CidadesDAO.java
public List<Cidades> pesquisaCidadesPorEstados(Integer id) {//join Session s = HibernateUtil.getSession(); Query q = s.createQuery("from Cidades cid where cid.estado.id = :estado order by cid.nome"); q.setParameter("estado", id); List<Cidades> lista = q.list(); s.close();//from ww w . j av a 2s .co m return lista; }
From source file:br.com.sescacre.dao.CidadesDAO.java
public Cidades pesquisaCidadesPorNome(String nome, Integer id) { Session s = HibernateUtil.getSession(); Query q = s.createQuery( "from Cidades cid where cid.nome like :cidade and cid.estado.id = :estado order by cid.nome"); q.setParameter("cidade", nome); q.setParameter("estado", id); Cidades c = (Cidades) q.uniqueResult(); s.close();//w ww. ja va 2s. c o m return c; }
From source file:br.com.sescacre.dao.CidadesDAO.java
public Integer contaCapital(Integer id) { Session s = HibernateUtil.getSession(); Query q = s .createQuery("select count(*) from Cidades cid where cid.estado.id = :estado and cid.capital = 1"); q.setParameter("estado", id); Integer i = ((Long) q.uniqueResult()).intValue(); s.close();/*from w w w . j a v a2 s. c o m*/ return i; }