List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listDocumentoDeEstagioMap(Curso curso) { Query query = this.sessionFactory.getCurrentSession().createSQLQuery( "select dis.nome as discente, dis.matricula, doc.email, doc.nome as docente, i.tipodedocumento, c.nome as curso\n" + "from requerimento r\n" + "join itemrequerimento i on i.requerimento_id=r.id\n" + "join usuario dis on r.usuario_id=dis.id\n" + "join perfil p_dis on p_dis.usuario_id=dis.id\n" + "join curso c on p_dis.curso_id=c.id\n" + "join perfil p_doc on p_doc.curso_id=p_dis.curso_id and p_doc.tipoperfil = :tipoPerfil\n" + "join usuario doc on p_doc.usuario_id=doc.id\n" + "where r.tiporequerimento = :tipoRequerimento and c.id = :cursoId and r.status = :status"); query.setString("tipoRequerimento", TipoRequerimentoEnum.DOCUMENTO_DE_ESTAGIO.name()); query.setString("tipoPerfil", PerfilEnum.COORDENADOR_DE_ESTAGIO.name()); query.setLong("cursoId", curso.getId()); query.setString("status", RequerimentoStatusEnum.EM_ANDAMENTO.name()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listSegundaChamadaDeProvaMap(RequerimentoStatusEnum status, Curso curso) { Query query = this.sessionFactory.getCurrentSession().createSQLQuery( "select dis.nome as discente, dis.matricula, doc.nome as docente, doc.email, d.nome as disciplina, t.nome as turma, c.nome as curso, i.dataprovaa as data_prova, r.datacriacao as data_requerimento\n" + "from requerimento r\n" + "join itemrequerimento i on i.requerimento_id=r.id\n" + "join turma t on i.turma_id=t.id\n" + "join disciplina d on t.disciplina_id=d.id\n" + "join usuario dis on r.usuario_id=dis.id\n" + "join perfil p on p.usuario_id=dis.id\n" + "join curso c on p.curso_id=c.id\n" + "join usuario doc on t.docente_id=doc.id\n" + "where r.tiporequerimento = :tipoRequerimento and r.status = :status\n" + (curso == null ? "" : "and c.id = :cursoId")); if (curso != null) { query.setLong("cursoId", curso.getId()); }//w w w.j a v a2 s . c o m query.setString("tipoRequerimento", TipoRequerimentoEnum.SEGUNDA_CHAMADA_DE_PROVA.name()); query.setString("status", status.name()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listSegundaChamadaDeProvaMap(RequerimentoStatusEnum status, Usuario usuario) { Query query = this.sessionFactory.getCurrentSession().createSQLQuery( "select dis.nome as discente, dis.matricula, doc.nome as docente, doc.email, d.nome as disciplina, t.nome as turma, c.nome as curso, i.dataprovaa as data_prova, r.datacriacao as data_requerimento\n" + "from requerimento r\n" + "join itemrequerimento i on i.requerimento_id=r.id\n" + "join turma t on i.turma_id=t.id\n" + "join disciplina d on t.disciplina_id=d.id\n" + "join usuario dis on r.usuario_id=dis.id\n" + "join perfil p on p.usuario_id=dis.id\n" + "join curso c on p.curso_id=c.id\n" + "join usuario doc on t.docente_id=doc.id\n" + "where r.tiporequerimento = :tipoRequerimento and doc.id = :usuarioId and r.status = :status"); query.setString("tipoRequerimento", TipoRequerimentoEnum.SEGUNDA_CHAMADA_DE_PROVA.name()); query.setString("status", status.name()); query.setLong("usuarioId", usuario.getId()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listTotalRequerimento(PerfilEnum perfil, Curso curso, List<RequerimentoStatusEnum> statusList, List<TipoRequerimentoEnum> tipoRequerimentoList) { List<String> tipoRequerimentoNames = new ArrayList<>(); List<String> statusNames = new ArrayList<>(); for (TipoRequerimentoEnum tipoRequerimento : tipoRequerimentoList) { tipoRequerimentoNames.add(tipoRequerimento.name()); }/* w w w .j a v a 2s . co m*/ for (RequerimentoStatusEnum status : statusList) { statusNames.add(status.name()); } Query query; if (perfil == null) { query = this.sessionFactory.getCurrentSession() .createSQLQuery("select c.nome as curso, r.tiporequerimento as requerimento,\n" + "r.status as status, count(r.tiporequerimento) as total\n" + "from requerimento r\n" + "join usuario u on u.id=r.usuario_id\n" + "join perfil p on p.usuario_id=u.id\n" + "join curso c on c.id=p.curso_id\n" + "group by c.id, c.nome, r.tiporequerimento, r.status\n" + "having r.status in :status\n" + "and r.tiporequerimento in :tipoRequerimento\n" + (curso == null ? "" : "and c.id = :cursoId\n") + "order by c.nome asc, r.tiporequerimento asc"); if (curso != null) { query.setLong("cursoId", curso.getId()); } } else { query = this.sessionFactory.getCurrentSession() .createSQLQuery("select coord.email, cdis.nome as curso,\n" + "r.tiporequerimento as requerimento,\n" + "r.status as status,\n" + "count(r.tiporequerimento) as total\n" + "from requerimento r\n" + "join usuario dis on dis.id=r.usuario_id\n" + "join perfil pdis on pdis.usuario_id=dis.id\n" + "join curso cdis on cdis.id=pdis.curso_id\n" + "join perfil pcoord on pcoord.curso_id=cdis.id\n" + "and pcoord.tipoperfil = :perfil\n" + "join usuario coord on pcoord.usuario_id=coord.id\n" + "group by coord.email, cdis.nome, r.tiporequerimento, r.status\n" + "having r.status in :status\n" + "and r.tiporequerimento in :tipoRequerimento\n" + "order by cdis.nome asc, r.tiporequerimento asc;\n"); query.setParameter("perfil", perfil.name()); } query.setParameterList("status", statusNames); query.setParameterList("tipoRequerimento", tipoRequerimentoNames); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:br.ufg.reqweb.dao.ReportDao.java
@Transactional(readOnly = true) public List<Map<String, ?>> listUsuarioMap(PerfilEnum tipoPerfil, Curso curso) { Query query = this.sessionFactory.getCurrentSession() .createSQLQuery("select u.matricula, u.nome, c.nome as curso, u.email, p.tipoperfil\n" + "from usuario u\n" + "join perfil p on p.usuario_id=u.id\n" + "full outer join curso c on p.curso_id=c.id\n" + "where p.tipoperfil = :tipoPerfil\n" + (curso == null ? "" : "and c.id = :cursoId\n") + "order by c.nome asc, u.nome asc;"); if (curso != null) { query.setLong("cursoId", curso.getId()); }// www .j a v a 2 s.c om query.setString("tipoPerfil", tipoPerfil.name()); query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP); return query.list(); }
From source file:ch.astina.hesperid.dao.hibernate.LocationDAOHibernate.java
License:Apache License
@Override public void delete(Location location) { String sql = "UPDATE contact SET location = NULL WHERE location = ?"; Query query = session.createSQLQuery(sql); query.setLong(0, location.getId()); query.executeUpdate();/*from w ww .j a va 2s . com*/ sql = "UPDATE asset SET location = NULL WHERE location = ?"; query = session.createSQLQuery(sql); query.setLong(0, location.getId()); query.executeUpdate(); session.delete(location); }
From source file:ch.astina.hesperid.dao.hibernate.MesRoleDAOHibernate.java
License:Apache License
@Override public void deleteMesRole(BusinessRole mesRole) { String sql = "UPDATE asset_contact SET business_role = NULL WHERE business_role = ?"; Query query = session.createSQLQuery(sql); query.setLong(0, mesRole.getId()); query.executeUpdate();/*from www . j a v a 2 s. com*/ session.delete(mesRole); }
From source file:ch.astina.hesperid.dao.hibernate.SystemDAOHibernate.java
License:Apache License
public void delete(System system) { String sql = "UPDATE asset SET system = NULL WHERE system = ?"; Query query = session.createSQLQuery(sql); query.setLong(0, system.getId()); query.executeUpdate();//w ww . j a va 2 s . c o m session.delete(system); }
From source file:ch.eggbacon.app.service.BuchungServiceImpl.java
License:Open Source License
@Override public List<Buchung> searchBuchungenByPersonId(Long id) { Query q = getSession().createQuery("FROM " + TABLE_NAME + " WHERE PersID = :personId"); q.setLong("personId", id); return q.list(); }
From source file:ch.eggbacon.app.service.RechungServiceImpl.java
License:Open Source License
@Override public List<Rechnung> searchRechnungenByPersonId(Long id) { BuchungService buchungService = new BuchungServiceImpl(); List<Buchung> buchungen = buchungService.searchBuchungenByPersonId(id); List<Rechnung> rechnungen = new ArrayList<>(); for (Buchung b : buchungen) { Query q = getSession().createQuery("FROM Rechnung WHERE buchungId = :buchungId"); q.setLong("buchungId", b.getPerson().getPersId()); rechnungen.add((Rechnung) q.uniqueResult()); }//w w w. j a va 2s . c o m return rechnungen; }