List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:br.gov.jfrj.siga.ex.relatorio.dinamico.relatorios.RelConsultaDocEntreDatas.java
License:Open Source License
public Collection processarDados() throws Exception { ExDao dao = ExDao.getInstance();//from ww w. ja v a2 s.co m final Query query = dao.getSessao().getNamedQuery("consultarMobilNoPeriodo"); //DpLotacao lot = new DpLotacao(); //lot.setSigla((String) parametros.get("lotacao")); //List<DpLotacao> listaLotacao = dao.consultar(lot, null); Long idLotacao = Long.valueOf((String) parametros.get("lotacao")); query.setLong("idLotacao", idLotacao); query.setString("dataInicial", (String) parametros.get("dataInicial")); query.setString("dataFinal", (String) parametros.get("dataFinal")); query.setString("URL", (String) parametros.get("link_siga")); List<Object[]> provResultList = query.list(); List<String> dados = new ArrayList<String>(); for (Object[] array : provResultList) { for (Object value : array) dados.add((String) value); } return dados; }
From source file:br.gov.jfrj.siga.ex.relatorio.dinamico.relatorios.RelConsultaDocEntreDatas.java
License:Open Source License
public Collection processarDadosLento() throws Exception { List<String> dados = new ArrayList<String>(); // HibernateUtil.configurarHibernate("/br/gov/jfrj/siga/hibernate/hibernate.cfg.xml"); ExDao dao = ExDao.getInstance();/* w w w .j a v a 2 s . c o m*/ final Query query = dao.getSessao().getNamedQuery("consultarMobilNoPeriodo"); DpLotacao lot = new DpLotacao(); lot.setSigla((String) parametros.get("lotacao")); List<DpLotacao> listaLotacao = dao.consultar(lot, null); query.setLong("idLotacao", new Long(listaLotacao.get(0).getId())); query.setString("dataInicial", (String) parametros.get("dataInicial")); query.setString("dataFinal", (String) parametros.get("dataFinal")); Query qryLotacaoTitular = HibernateUtil.getSessao() .createQuery("from DpLotacao lot " + "where lot.dataFimLotacao is null " + "and lot.orgaoUsuario = " + parametros.get("orgaoUsuario") + " and lot.siglaLotacao = '" + parametros.get("lotacaoTitular") + "'"); DpLotacao lotaTitular = (DpLotacao) qryLotacaoTitular.uniqueResult(); DpPessoa titular = ExDao.getInstance().consultar(new Long((String) parametros.get("idTit")), DpPessoa.class, false); ExMobil mob = null; List provResultList = query.list(); for (Iterator iterator = provResultList.iterator(); iterator.hasNext();) { BigDecimal idMobil = (BigDecimal) iterator.next(); if (idMobil != null) { mob = dao.consultar(new Long(idMobil.longValue()), ExMobil.class, false); dados.add(mob.getSigla()); dados.add((String) parametros.get("link_siga") + mob.getSigla()); // dados.add(mob.getExDocumento().getDescrDocumento()); dados.add(Ex.getInstance().getBL().descricaoConfidencialDoDocumento(mob, titular, lotaTitular)); dados.add(mob.getExDocumento().getLotaCadastrante().getSigla()); } } return dados; }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public Long obterProximoNumero(final ExDocumento doc, Long anoEmissao) throws SQLException { Query query = getSessao().getNamedQuery("obterProximoNumero"); query.setLong("idOrgaoUsu", doc.getOrgaoUsuario().getId()); query.setLong("idFormaDoc", doc.getExFormaDocumento().getId()); query.setLong("anoEmissao", anoEmissao); return (Long) query.uniqueResult(); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List consultarPorFiltro(final ExMobilDaoFiltro flt, final int offset, final int itemPagina, DpPessoa titular, DpLotacao lotaTitular) { Query query = getSessao().getNamedQuery("consultarPorFiltro"); if (offset > 0) { query.setFirstResult(offset);// ww w .j av a 2s .com } if (itemPagina > 0) { query.setMaxResults(itemPagina); } query.setProperties(flt); query.setLong("titular", titular.getIdPessoaIni() != null ? titular.getIdPessoaIni() : 0); query.setLong("lotaTitular", lotaTitular.getIdLotacaoIni() != null ? lotaTitular.getIdLotacaoIni() : 0); List l = query.list(); return l; }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public void preencherParametros(final IExMobilDaoFiltro flt, final Query query) { if (flt.getUltMovIdEstadoDoc() != null && flt.getUltMovIdEstadoDoc() != 0) { query.setLong("ultMovIdEstadoDoc", flt.getUltMovIdEstadoDoc()); }/*from www. j a v a 2s . c o m*/ if (flt.getUltMovRespSelId() != null && flt.getUltMovRespSelId() != 0) { query.setLong("ultMovRespSelId", flt.getUltMovRespSelId()); } if (flt.getUltMovLotaRespSelId() != null && flt.getUltMovLotaRespSelId() != 0) { query.setLong("ultMovLotaRespSelId", flt.getUltMovLotaRespSelId()); } if (flt.getIdTipoMobil() != null && flt.getIdTipoMobil() != 0) { query.setLong("idTipoMobil", flt.getIdTipoMobil()); } if (flt.getNumSequencia() != null && flt.getNumSequencia() != 0) { query.setLong("numSequencia", flt.getNumSequencia()); } if (flt.getIdOrgaoUsu() != null && flt.getIdOrgaoUsu() != 0) { query.setLong("idOrgaoUsu", flt.getIdOrgaoUsu()); } if (flt.getAnoEmissao() != null && flt.getAnoEmissao() != 0) { query.setLong("anoEmissao", flt.getAnoEmissao()); } if (flt.getNumExpediente() != null && flt.getNumExpediente() != 0) { query.setLong("numExpediente", flt.getNumExpediente()); } if (flt.getIdTpDoc() != null && flt.getIdTpDoc() != 0) { query.setLong("idTpDoc", flt.getIdTpDoc()); } if (flt.getIdFormaDoc() != null && flt.getIdFormaDoc() != 0) { query.setLong("idFormaDoc", flt.getIdFormaDoc()); } if (flt.getIdTipoFormaDoc() != null && flt.getIdTipoFormaDoc() != 0) { query.setLong("idTipoFormaDoc", flt.getIdTipoFormaDoc()); } if (flt.getClassificacaoSelId() != null && flt.getClassificacaoSelId() != 0) { query.setLong("classificacaoSelId", flt.getClassificacaoSelId()); } if (flt.getDescrDocumento() != null && !flt.getDescrDocumento().trim().equals("")) { query.setString("descrDocumento", "%" + flt.getDescrDocumento().toUpperCase() + "%"); } if (flt.getDtDoc() != null) { query.setString("dtDoc", new SimpleDateFormat("dd/MM/yyyy").format(flt.getDtDoc())); } if (flt.getDtDocFinal() != null) { query.setString("dtDocFinal", new SimpleDateFormat("dd/MM/yyyy").format(flt.getDtDocFinal())); } if (flt.getNumAntigoDoc() != null && !flt.getNumAntigoDoc().trim().equals("")) { query.setString("numAntigoDoc", "%" + flt.getNumAntigoDoc().toUpperCase() + "%"); } if (flt.getDestinatarioSelId() != null && flt.getDestinatarioSelId() != 0) { query.setLong("destinatarioSelId", flt.getDestinatarioSelId()); } if (flt.getLotacaoDestinatarioSelId() != null && flt.getLotacaoDestinatarioSelId() != 0) { query.setLong("lotacaoDestinatarioSelId", flt.getLotacaoDestinatarioSelId()); } if (flt.getNmDestinatario() != null && !flt.getNmDestinatario().trim().equals("")) { query.setString("nmDestinatario", "%" + flt.getNmDestinatario() + "%"); } if (flt.getCadastranteSelId() != null && flt.getCadastranteSelId() != 0) { query.setLong("cadastranteSelId", flt.getCadastranteSelId()); } if (flt.getLotaCadastranteSelId() != null && flt.getLotaCadastranteSelId() != 0) { query.setLong("lotaCadastranteSelId", flt.getLotaCadastranteSelId()); } if (flt.getSubscritorSelId() != null && flt.getSubscritorSelId() != 0) { query.setLong("subscritorSelId", flt.getSubscritorSelId()); } if (flt.getNmSubscritorExt() != null && !flt.getNmSubscritorExt().trim().equals("")) { query.setString("nmSubscritorExt", "%" + flt.getNmSubscritorExt().toUpperCase() + "%"); } if (flt.getOrgaoExternoSelId() != null && flt.getOrgaoExternoSelId() != 0) { query.setLong("orgaoExternoSelId", flt.getOrgaoExternoSelId()); } if (flt.getNumExtDoc() != null && !flt.getNumExtDoc().trim().equals("")) { query.setString("numExtDoc", "%" + flt.getNumExtDoc() + "%"); } if (flt.getIdMod() != null && flt.getIdMod() != 0) { ExModelo mod = ExDao.getInstance().consultar(flt.getIdMod(), ExModelo.class, false); query.setLong("hisIdIni", mod.getHisIdIni()); } }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List consultarPorFiltroOld(final ExMobilDaoFiltro flt, final int offset, final int itemPagina, DpPessoa titular, DpLotacao lotaTitular) { try {/*ww w .j a v a2 s. c o m*/ final Query query = getSessao().getNamedQuery("consultarPorFiltro"); if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } query.setProperties(flt); if (titular.getIdPessoaIni() != null) query.setLong("titular", titular.getIdPessoaIni()); else query.setLong("titular", 0); if (lotaTitular.getIdLotacaoIni() != null) query.setLong("lotaTitular", lotaTitular.getIdLotacaoIni()); else query.setLong("lotaTitular", 0); if (flt.getDescrDocumento() != null) query.setString("descrDocumento", flt.getDescrDocumento().toUpperCase().replace(' ', '%')); return query.list(); } catch (final NullPointerException e) { return null; } }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public Integer consultarQuantidadePorFiltro(final ExMobilDaoFiltro flt, DpPessoa titular, DpLotacao lotaTitular) {/*ww w .j av a 2 s . co m*/ Query query = getSessao().getNamedQuery("consultarQuantidadePorFiltro"); query.setProperties(flt); query.setLong("titular", titular.getIdPessoaIni()); query.setLong("lotaTitular", lotaTitular.getIdLotacaoIni()); long tempoIni = System.nanoTime(); Long l = (Long) query.uniqueResult(); long tempoTotal = System.nanoTime() - tempoIni; System.out.println("consultarQuantidadePorFiltro: " + tempoTotal / 1000000 + ", resultado: " + l); return l.intValue(); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExDocumento> consultarPorModeloEAssinatura(CpOrgaoUsuario orgaoUsu, ExModelo mod, Date dtAssinaturaIni, Date dtAssinaturaFim) { if (mod != null) { final Query query = getSessao().getNamedQuery("consultarPorModeloEAssinatura"); query.setLong("idOrgaoUsu", orgaoUsu.getIdOrgaoUsu()); query.setLong("idMod", mod.getIdMod()); query.setDate("dataIni", dtAssinaturaIni); query.setDate("dataFim", dtAssinaturaFim); return query.list(); }// ww w . j a va 2s . co m return null; }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExDocumento> consultarPorModeloParaPublicar(CpOrgaoUsuario orgaoUsu) { final Query query = getSessao().getNamedQuery("consultarPorModeloParaPublicarBI"); query.setLong("idOrgaoUsu", orgaoUsu.getIdOrgaoUsu()); return query.list(); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExDocumento> consultarPorBoletimParaPublicar(ExDocumento doc) { final Query query = getSessao().getNamedQuery("consultarPorBoletimParaPublicarBI"); query.setLong("idDoc", doc.getIdDoc()); return query.list(); }