Example usage for org.hibernate Session getNamedQuery

List of usage examples for org.hibernate Session getNamedQuery

Introduction

In this page you can find the example usage for org.hibernate Session getNamedQuery.

Prototype

org.hibernate.Query getNamedQuery(String queryName);

Source Link

Document

Create a Query instance for the named query.

Usage

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

public Curso buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Curso curso = null;//from  ww w.ja v a 2s.c o  m

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

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

    return curso;
}

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

public List<Disciplina> listar() {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    List<Disciplina> cursos = null;

    try {/*from w ww.jav a  2  s.c  o m*/
        Query consulta = sessao.getNamedQuery("Disciplina.listar");
        cursos = consulta.list();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }
    return cursos;
}

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

public Disciplina buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Disciplina disciplina = null;//from  ww  w.j a  v a 2  s.  co  m

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

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

    return disciplina;
}

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

public List<Extensao> listar() {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    List<Extensao> extensaos = null;

    try {/*from   w  ww .  ja va  2s. com*/
        Query consulta = sessao.getNamedQuery("Extensao.listar");
        extensaos = consulta.list();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }
    return extensaos;
}

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

public Extensao buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Extensao extensao = null;//ww  w .  j  a  v a2  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 List<Monitoria> listar() {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    List<Monitoria> monitorias = null;

    try {/*from w  w  w .  jav  a2s. c om*/
        Query consulta = sessao.getNamedQuery("Monitoria.listar");
        monitorias = consulta.list();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }
    return monitorias;
}

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

public Monitoria buscarPorCodigo(Long codigo) {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    Monitoria curso = null;//from  www .  java  2 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 List<Professor> listar() {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    List<Professor> professores = null;

    try {//from  w  ww  .j a va  2s  .com
        Query consulta = sessao.getNamedQuery("Professor.listar");
        professores = consulta.list();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }
    return professores;
}

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 .jav a 2s .  co 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 List<TermoAutorizacaoExtensao> listar() {
    Session sessao = HibernateUtil.getSessionFactory().openSession();
    List<TermoAutorizacaoExtensao> termoAutorizacaoExtensaos = null;

    try {// w  ww  .j a v a2  s  .com
        Query consulta = sessao.getNamedQuery("Monitoria.listar");
        termoAutorizacaoExtensaos = consulta.list();
    } catch (RuntimeException ex) {
        throw ex;
    } finally {
        sessao.close();
    }
    return termoAutorizacaoExtensaos;
}