List of usage examples for org.hibernate Query setString
@Deprecated @SuppressWarnings("unchecked") default Query<R> setString(String name, String val)
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
public CpServico consultarPorSiglaCpServico(String siglaServico) { final Query query = getSessao().getNamedQuery("consultarPorSiglaStringCpServico"); query.setString("siglaServico", siglaServico); // query.setFlushMode(FlushMode.MANUAL); final List<CpServico> l = query.list(); if (l.size() != 1) { return null; }//from ww w .j av a2 s . com return l.get(0); }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public Object consultaDadosBasicos(final String nmUsuario) throws AplicacaoException { try {//from w w w .j av a 2 s . c o m final Query qry = getSessao().getNamedQuery("consultarDadosBasicos"); qry.setString("nmUsuario", nmUsuario); // Verifica se existe numeros no login do usuario if (nmUsuario.substring(2).matches("^[0-9]*$")) qry.setString("sesbPessoa", nmUsuario.substring(0, 2)); else // se nao ha numeros atribui RJ por default qry.setString("sesbPessoa", "RJ"); // Cache was disabled because it would interfere with the // "change password" action. // qry.setCacheable(true); // qry.setCacheRegion("query.IdentidadeCadastrante"); final Object obj = qry.list(); return obj; } catch (Throwable e) { throw new AplicacaoException( "Ocorreu um erro tentando carregar os dados basicos para o usuario '" + nmUsuario + "'.", 0, e); } }
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();// www. j ava 2 s .c om 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();/*ww w .ja v a 2 s . c om*/ 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 void preencherParametros(final IExMobilDaoFiltro flt, final Query query) { if (flt.getUltMovIdEstadoDoc() != null && flt.getUltMovIdEstadoDoc() != 0) { query.setLong("ultMovIdEstadoDoc", flt.getUltMovIdEstadoDoc()); }//from w w w. j a va 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 {//from w w w . ja v a 2 s . com 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 List<ExPreenchimento> consultar(ExPreenchimento exPreenchimento) { try {/*from www. java 2 s. c o m*/ final Query query = getSessao().getNamedQuery("consultarPorFiltroExPreenchimento"); if (exPreenchimento.getNomePreenchimento() != null) query.setString("nomePreenchimento", exPreenchimento.getNomePreenchimento().toUpperCase().replace(' ', '%')); else query.setString("nomePreenchimento", ""); if (exPreenchimento.getDpLotacao() != null) query.setLong("lotacao", exPreenchimento.getDpLotacao().getIdLotacao()); else query.setLong("lotacao", 0); if (exPreenchimento.getExModelo() != null) query.setLong("modelo", exPreenchimento.getExModelo().getHisIdIni()); else query.setLong("modelo", 0); final List<ExPreenchimento> l = query.list(); return l; } catch (final NullPointerException e) { return null; } }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExClassificacao> listarExClassificacaoPorNivel(String mascara, String exceto) { Query q = getSessao().getNamedQuery("consultarExClassificacaoComExcecao"); q.setString("mascara", mascara); q.setString("exceto", exceto); return q.list(); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExClassificacao> listarExClassificacaoPorNivel(String mascara) { Query q = getSessao().getNamedQuery("consultarExClassificacaoPorMascara"); q.setString("mascara", mascara); q.setString("descrClassificacao", ""); return q.list(); }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExClassificacao> consultarPorFiltro(final ExClassificacaoDaoFiltro flt, final int offset, final int itemPagina) { String descrClassificacao = ""; MascaraUtil m = MascaraUtil.getInstance(); if (flt.getDescricao() != null) { String d = flt.getDescricao(); if (d.length() > 0 && m.isCodificacao(d)) { descrClassificacao = m.formatar(d); } else {/*w ww . j av a 2 s. com*/ descrClassificacao = d; } } final Query query = getSessao().getNamedQuery("consultarPorFiltroExClassificacao"); if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } if (flt.getSigla() == null || flt.getSigla().equals("")) { query.setString("mascara", MascaraUtil.getInstance().getMscTodosDoMaiorNivel()); } else { query.setString("mascara", MascaraUtil.getInstance().getMscFilho(flt.getSigla().toString(), true)); } query.setString("descrClassificacao", descrClassificacao.toUpperCase().replace(' ', '%')); query.setString("descrClassificacaoSemAcento", Texto.removeAcentoMaiusculas(descrClassificacao).replace(' ', '%')); final List<ExClassificacao> l = query.list(); return l; }