List of usage examples for org.hibernate Query setMaxResults
@Override
Query<R> setMaxResults(int maxResult);
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<DpFuncaoConfianca> consultarPorFiltro(final DpFuncaoConfiancaDaoFiltro o, final int offset, final int itemPagina) { try {// w ww. ja v a 2s . c o m final Query query = getSessao().getNamedQuery("consultarPorFiltroDpFuncaoConfianca"); if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } String s = o.getNome(); if (s != null) s = s.replace(' ', '%'); query.setString("nome", s); if (o.getIdOrgaoUsu() != null) query.setLong("idOrgaoUsu", o.getIdOrgaoUsu()); else query.setLong("idOrgaoUsu", 0); final List<DpFuncaoConfianca> l = query.list(); return l; } catch (final NullPointerException e) { return null; } }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<DpLotacao> consultarPorFiltro(final DpLotacaoDaoFiltro o, final int offset, final int itemPagina) { try {// w ww. j ava 2 s . c om final Query query; if (!o.isBuscarFechadas()) query = getSessao().getNamedQuery("consultarPorFiltroDpLotacao"); else query = getSessao().getNamedQuery("consultarPorFiltroDpLotacaoInclusiveFechadas"); if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } query.setString("nome", o.getNome() == null ? "" : o.getNome().replace(' ', '%')); if (o.getIdOrgaoUsu() != null) query.setLong("idOrgaoUsu", o.getIdOrgaoUsu()); else query.setLong("idOrgaoUsu", 0); query.setCacheable(true); query.setCacheRegion(CACHE_QUERY_CONFIGURACAO); final List<DpLotacao> l = query.list(); return l; } catch (final NullPointerException e) { return null; } }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<CpGrupo> consultarPorFiltro(final CpGrupoDaoFiltro o, final int offset, final int itemPagina) { try {//from w w w . j a v a 2 s. c o m final Query query; if (o.getNome() != null) { query = getSessao().getNamedQuery("consultarCpGrupoPorCpTipoGrupoIdENome"); query.setString("siglaGrupo", o.getNome()); } else { query = getSessao().getNamedQuery("consultarCpGrupoPorCpTipoGrupoId"); } if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } if (o.getIdTpGrupo() != null) { query.setLong("idTpGrupo", o.getIdTpGrupo()); } else { query.setLong("idTpGrupo", 0); } final List<CpGrupo> l = query.list(); return l; } catch (final NullPointerException e) { return null; } }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List<DpPessoa> consultarPorFiltro(final DpPessoaDaoFiltro flt, final int offset, final int itemPagina) { try {/*w w w.j ava 2s . c o m*/ final Query query; if (!flt.isBuscarFechadas()) query = getSessao().getNamedQuery("consultarPorFiltroDpPessoa"); else query = getSessao().getNamedQuery("consultarPorFiltroDpPessoaInclusiveFechadas"); if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } query.setString("nome", flt.getNome().toUpperCase().replace(' ', '%')); if (!flt.isBuscarFechadas()) query.setString("situacaoFuncionalPessoa", flt.getSituacaoFuncionalPessoa()); if (flt.getIdOrgaoUsu() != null) query.setLong("idOrgaoUsu", flt.getIdOrgaoUsu()); else query.setLong("idOrgaoUsu", 0); if (flt.getLotacao() != null) query.setLong("lotacao", flt.getLotacao().getId()); else query.setLong("lotacao", 0); final List<DpPessoa> 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 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);//from w w w . j a v a2 s. c om } 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 List consultarPorFiltroOtimizado(final ExMobilDaoFiltro flt, final int offset, final int itemPagina, DpPessoa titular, DpLotacao lotaTitular) { long tempoIni = System.nanoTime(); Query query = getSessao() .createQuery(montadorQuery.montaQueryConsultaporFiltro(flt, titular, lotaTitular, false)); preencherParametros(flt, query);/*ww w. java2s . co m*/ if (offset > 0) { query.setFirstResult(offset); } if (itemPagina > 0) { query.setMaxResults(itemPagina); } List l = query.list(); long tempoTotal = System.nanoTime() - tempoIni; System.out.println( "consultarPorFiltroOtimizado: " + tempoTotal / 1000000 + " ms -> " + query + ", resultado: " + l); return l; }
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.j a va2 s . co 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 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 {//from w w w.j a v a 2 s . c o m 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; }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExItemDestinacao> consultarParaArquivarIntermediarioEmLote(DpLotacao lot, int offset) { final Query query = getSessao().getNamedQuery("consultarParaArquivarIntermediarioEmLote"); query.setLong("idOrgaoUsu", lot.getOrgaoUsuario().getIdOrgaoUsu()); query.setFirstResult(offset);/*from www . j av a 2 s . c o m*/ query.setMaxResults(100); List<Object[]> results = query.list(); List<ExItemDestinacao> listaFinal = new ArrayList<ExItemDestinacao>(); for (Object[] result : results) { listaFinal.add(new ExItemDestinacao(result)); } return listaFinal; }
From source file:br.gov.jfrj.siga.hibernate.ExDao.java
License:Open Source License
public List<ExItemDestinacao> consultarParaArquivarPermanenteEmLote(DpLotacao lot, int offset) { final Query query = getSessao().getNamedQuery("consultarParaArquivarPermanenteEmLote"); query.setLong("idOrgaoUsu", lot.getOrgaoUsuario().getIdOrgaoUsu()); query.setFirstResult(offset);/* w w w.java2 s . c om*/ query.setMaxResults(100); List<Object[]> results = query.list(); List<ExItemDestinacao> listaFinal = new ArrayList<ExItemDestinacao>(); for (Object[] result : results) { listaFinal.add(new ExItemDestinacao(result)); } return listaFinal; }