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.com.sigcopex.dao.ExtensaoDAO.java

public Extensao buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Extensao extensao = null;// w  w  w  .  j ava  2 s  .  c  o  m

    try {
        Query consulta = sessao.getNamedQuery("Extensao.buscarPorCodigo");
        consulta.setLong("codigo", codigo);

        extensao = (Extensao) consulta.uniqueResult();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }

    return extensao;
}

From source file:br.com.sigcopex.dao.MonitoriaDAO.java

public Monitoria buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Monitoria curso = null;/*from   w w  w  .j  a v  a2 s .  c o m*/

    try {

        Query consulta = sessao.getNamedQuery("Monitoria.buscarPorCodigo");
        consulta.setLong("codigo", codigo);

        curso = (Monitoria) consulta.uniqueResult();

    }

    catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }

    return curso;

}

From source file:br.com.sigcopex.dao.ProfessorDAO.java

public Professor buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Professor professor = null;/*w  w w .  j  a  v a2  s .c o m*/

    try {
        Query consulta = sessao.getNamedQuery("Professor.buscarPorCodigo");
        consulta.setLong("codigo", codigo);

        professor = (Professor) consulta.uniqueResult();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }

    return professor;
}

From source file:br.com.sigcopex.dao.TermoAutorizacaoExtensaoDAO.java

public TermoAutorizacaoExtensao buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    TermoAutorizacaoExtensao termoAutorizacaoExtensao = null;

    try {//from  ww  w  .  j  a  v a  2 s .c  o  m

        Query consulta = sessao.getNamedQuery("TermoAutorizacaoExtensao.buscarPorCodigo");
        consulta.setLong("codigo", codigo);

        termoAutorizacaoExtensao = (TermoAutorizacaoExtensao) consulta.uniqueResult();

    }

    catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }

    return termoAutorizacaoExtensao;

}

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

License:Open Source License

@SuppressWarnings("unchecked")
public CpServico consultarPorSigla(final CpServico o) {
    final Query query = getSessao().getNamedQuery("consultarPorSiglaCpServico");
    query.setString("siglaServico", o.getSiglaServico());
    query.setLong("idServicoPai", o.getCpServicoPai() == null ? 0 : o.getCpServicoPai().getIdServico());

    // Renato: Comentei a linha abaixo pois  nao entendi porque foi feito
    // dessa forma.
    // query.setFlushMode(FlushMode.MANUAL);

    query.setCacheable(true);//from w ww. ja  v  a  2  s .c  om
    query.setCacheRegion(CACHE_QUERY_HOURS);

    final List<CpServico> 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 List<DpCargo> consultarPorFiltro(final DpCargoDaoFiltro o, final int offset, final int itemPagina) {
    try {/* ww w  .ja v  a 2 s .co  m*/
        final Query query = getSessao().getNamedQuery("consultarPorFiltroDpCargo");
        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<DpCargo> 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

public int consultarQuantidade(final DpCargoDaoFiltro o) {
    try {/* ww  w  .  ja  va 2s .  com*/
        final Query query = getSessao().getNamedQuery("consultarQuantidadeDpCargo");
        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

@SuppressWarnings("unchecked")
public List<DpFuncaoConfianca> consultarPorFiltro(final DpFuncaoConfiancaDaoFiltro o, final int offset,
        final int itemPagina) {
    try {//from   www .j av  a 2s.  co 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<CpAplicacaoFeriado> listarAplicacoesFeriado(final CpAplicacaoFeriado apl) {
    final Query query = getSessao().getNamedQuery("listarAplicacoesFeriado");
    query.setLong("cpOcorrenciaFeriado", apl.getCpOcorrenciaFeriado().getId());

    query.setCacheable(true);//  w w  w .  j av a  2  s.  co m
    query.setCacheRegion(CACHE_QUERY_HOURS);

    final List<CpAplicacaoFeriado> l = query.list();
    return l;
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public DpFuncaoConfianca consultarPorSigla(final DpFuncaoConfianca o) {
    final Query query = getSessao().getNamedQuery("consultarPorSiglaDpFuncaoConfianca");
    query.setLong("idFuncao", o.getIdFuncao());
    if (o.getOrgaoUsuario() != null)
        query.setLong("idOrgaoUsu", o.getOrgaoUsuario().getIdOrgaoUsu());
    else//  w  w  w  . j  ava 2s  . com
        query.setLong("idOrgaoUsu", 0);

    final List<DpFuncaoConfianca> l = query.list();
    if (l.size() != 1)
        return null;
    return l.get(0);
}