Example usage for org.hibernate Session get

List of usage examples for org.hibernate Session get

Introduction

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

Prototype

Object get(String entityName, Serializable id);

Source Link

Document

Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.

Usage

From source file:br.uem.projetoExtensao.DAO.AnexoDAO.java

public boolean alterar(Session session) {
    boolean r = true;
    try {//from  w w w  . ja va  2 s  .  c o m
        Anexo anexo = new Anexo();
        anexo = (Anexo) session.get(Anexo.class, new Long(anexo.getCd_arquivo()));
        if (anexo.getCd_arquivo() > 0) {
            //campos a serem alterados

            //                anexo.setCd_conanex(getCd_conanex());
            //                anexo.setCd_convenio(getCd_convenio());
            //                anexo.setde_arquivo(getde_arquivo());
            //                anexo.setTp_anexo(getTp_anexo());
            //                anexo.setDe_observacao(getDe_observacao());

        }

    } catch (Exception e) {
        r = false;
    }
    return r;
}

From source file:br.uem.projetoExtensao.DAO.AreaAbrangenciaDAO.java

public boolean excluir(Session session, Long id_abrangencia) {
    boolean r = true;
    try {// w ww  .j a  v a2s.c o m
        AreaAbrangencia sistema = (AreaAbrangencia) session.get(AreaAbrangencia.class, id_abrangencia);
        if (sistema.getCd_area() > 0) {
            //campos a serem alterados

            session.delete(sistema);
        }

    } catch (Exception e) {
        r = false;
    }
    return r;
}

From source file:br.uem.projetoExtensao.DAO.InscricaoDAO.java

public boolean alterar(Session session, Inscricao insc) {
    boolean r = true;
    try {// w  ww.  j  a  v a  2  s  . c o m
        Inscricao sistema = (Inscricao) session.get(Inscricao.class, insc.getId());
        if (sistema.getId() > 0) {

            //campos a serem alterados
            sistema.setLocalInscricao(insc.getLocalInscricao());
            sistema.setDt_inscricoesInicio(insc.getDt_inscricoesInicio());
            sistema.setDt_inscricoesFim(insc.getDt_inscricoesFim());
            sistema.setHorarioInicio(insc.getHorarioInicio());
            sistema.setHorarioFinal(insc.getHorarioFinal());
        }
    } catch (Exception e) {
        r = false;
    }
    return r;
}

From source file:br.ufg.calendario.dao.CalendarioDao.java

@Transactional(readOnly = true)
public Calendario buscarPorId(Long id) {
    Session session = sessionFactory.getCurrentSession();
    return (Calendario) session.get(Calendario.class, id);
}

From source file:br.ufg.calendario.dao.EventoDao.java

@Transactional(readOnly = true)
public Evento buscarPorId(Long id) {
    Session session = sessionFactory.getCurrentSession();
    return (Evento) session.get(Evento.class, id);
}

From source file:br.ufg.calendario.dao.InteressadoDao.java

@Transactional(readOnly = true)
public Interessado buscarPorId(Long id) {
    Session session = sessionFactory.getCurrentSession();
    return (Interessado) session.get(Interessado.class, id);
}

From source file:br.ufg.calendario.dao.RegionalDao.java

@Transactional(readOnly = true)
public Regional buscarPorId(Long id) {
    Session session = sessionFactory.getCurrentSession();
    return (Regional) session.get(Regional.class, id);
}

From source file:br.ufg.calendario.dao.UsuarioDao.java

@Transactional(readOnly = true)
public Usuario buscarPorId(Long id) {
    Session session = sessionFactory.getCurrentSession();
    return (Usuario) session.get(Usuario.class, id);
}

From source file:br.ufg.inf.es.fs.contpatri.persistencia.dao.GenericDAOImpl.java

License:GNU General Public License

@Override
public T findByID(Class clazz, ID id) {
    HibernateUtil.beginTransaction();/*  www  . j  a  v  a2s .co  m*/
    Session hibernateSession = this.getSession();
    T t = null;
    t = (T) hibernateSession.get(clazz, id);
    HibernateUtil.commitTransaction();
    return t;
}

From source file:br.ufg.inf.es.fs.contpatri.web.persistencia.dao.GenericDAOImpl.java

License:GNU General Public License

@Override
public T findByID(Class clazz, int id) {
    Session hibernateSession = this.getSession();
    T t = null;//  w  ww.  j  a  va  2s .c  om
    t = (T) hibernateSession.get(clazz, id);
    return t;
}