Example usage for org.hibernate Query setLong

List of usage examples for org.hibernate Query setLong

Introduction

In this page you can find the example usage for org.hibernate Query setLong.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setLong(String name, long val) 

Source Link

Document

Bind a named long-valued parameter.

Usage

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

public int consultarQuantidade(final DpFuncaoConfiancaDaoFiltro o) {
    try {//  w  ww .j  a v a  2 s  .  co  m
        final Query query = getSessao().getNamedQuery("consultarQuantidadeDpFuncaoConfianca");
        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 int l = ((Long) query.uniqueResult()).intValue();
        return l;
    } catch (final NullPointerException e) {
        return 0;
    }
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

public List<DpPessoa> consultarPessoasComFuncaoConfianca(Long idFuncao) {
    final Query query = getSessao().getNamedQuery("consultarPessoasComFuncaoConfianca");
    query.setLong("idFuncaoConfianca", idFuncao);
    return query.list();
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<DpPessoa> consultarPessoasComCargo(Long idCargo) {
    final Query query = getSessao().getNamedQuery("consultarPessoasComCargo");
    query.setLong("idCargo", idCargo);
    return query.list();
}

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 {//ww w  .  j av  a2  s.c  o m
        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 DpLotacao consultarPorSigla(final DpLotacao o) {
    final Query query = getSessao().getNamedQuery("consultarPorSiglaDpLotacao");
    query.setString("siglaLotacao", o.getSigla());
    if (o.getOrgaoUsuario() != null)
        if (o.getOrgaoUsuario().getIdOrgaoUsu() != null)
            query.setLong("idOrgaoUsu", o.getOrgaoUsuario().getIdOrgaoUsu());
        else//from   ww w . j a v  a2  s  . co m
            query.setLong("idOrgaoUsu", consultarPorSigla(o.getOrgaoUsuario()).getId());
    else
        query.setLong("idOrgaoUsu", 0);

    query.setCacheable(true);
    query.setCacheRegion(CACHE_QUERY_CONFIGURACAO);
    final List<DpLotacao> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public DpLotacao consultarPorIdInicial(Class<DpLotacao> clazz, final Long idInicial) {
    final Query query = getSessao().getNamedQuery("consultarPorIdInicialDpLotacao");
    query.setLong("idLotacaoIni", idInicial);

    query.setCacheable(true);//from   ww  w .  ja va  2 s . com
    query.setCacheRegion(CACHE_QUERY_CONFIGURACAO);
    final List<DpLotacao> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public DpLotacao consultarPorIdInicialInclusiveLotacaoFechada(Class<DpLotacao> clazz, final Long idInicial) {
    final Query query = getSessao().getNamedQuery("consultarPorIdInicialDpLotacaoInclusiveFechada");
    query.setLong("idLotacaoIni", idInicial);

    query.setCacheable(true);//ww w. j  a va 2s  .  c  om
    query.setCacheRegion(CACHE_QUERY_CONFIGURACAO);
    final List<DpLotacao> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

public int consultarQuantidade(final DpLotacaoDaoFiltro o) {
    try {/* w ww .  jav a 2 s.  co m*/
        final Query query;

        if (!o.isBuscarFechadas())
            query = getSessao().getNamedQuery("consultarQuantidadeDpLotacao");
        else
            query = getSessao().getNamedQuery("consultarQuantidadeDpLotacaoInclusiveFechadas");

        query.setString("nome", 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 int l = ((Long) query.uniqueResult()).intValue();
        return l;
    } catch (final NullPointerException e) {
        return 0;
    }
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public CpGrupo consultarPorSigla(final CpGrupo o) {
    final Query query = getSessao().getNamedQuery("consultarPorSiglaCpGrupo");
    query.setString("siglaGrupo", o.getSigla());
    if (o.getOrgaoUsuario() != null)
        query.setLong("idOrgaoUsu", o.getOrgaoUsuario().getIdOrgaoUsu());
    else//from  w  w w.j  a v a2s  .c  o  m
        query.setLong("idOrgaoUsu", 0);
    query.setCacheable(true);
    query.setCacheRegion(CACHE_QUERY_HOURS);
    final List<CpGrupo> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}

From source file:br.gov.jfrj.siga.dp.dao.CpDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public CpPerfil consultarPorSigla(final CpPerfil o) {
    final Query query = getSessao().getNamedQuery("consultarPorSiglaCpGrupo");
    query.setString("siglaGrupo", o.getSigla());
    if (o.getOrgaoUsuario() != null)
        query.setLong("idOrgaoUsu", o.getOrgaoUsuario().getIdOrgaoUsu());
    else//  w ww . jav  a2 s  .co  m
        query.setLong("idOrgaoUsu", 0);
    query.setCacheable(true);
    query.setCacheRegion(CACHE_QUERY_HOURS);
    final List<CpPerfil> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}