Example usage for org.hibernate Session load

List of usage examples for org.hibernate Session load

Introduction

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

Prototype

void load(Object object, Serializable id);

Source Link

Document

Read the persistent state associated with the given identifier into the given transient instance.

Usage

From source file:com.ecama.dao.FilesDAOImpl.java

@Override
public void delete(int id) {
    Session session = this.sessionFactory.getCurrentSession();
    Files f = (Files) session.load(Files.class, new Integer(id));
    if (null != f) {
        session.delete(f);/* www  . j a v  a2s  . co  m*/
    }
}

From source file:com.ecama.dao.ImagesDAOImpl.java

@Override
public void removeImages(int id) {
    Session session = this.sessionFactory.getCurrentSession();
    Images img = (Images) session.load(Images.class, new Integer(id));
    if (null != img) {
        session.delete(img);//from   w  w w. ja va 2  s. c  o m
    }
}

From source file:com.ecama.dao.UserDAOImpl.java

@Override
public User getUserById(int id) {
    Session session = this.sessionFactory.getCurrentSession();
    User u = (User) session.load(User.class, new Integer(id));
    logger.info("User loaded successfully, User details=" + u);
    return u;//from   w w w.j a v  a2  s .  c  om
}

From source file:com.ecama.dao.UserDAOImpl.java

@Override
public void removeUser(int id) {
    Session session = this.sessionFactory.getCurrentSession();
    User u = (User) session.load(User.class, new Integer(id));
    if (null != u) {
        session.delete(u);/*from  www .  ja v a2 s.  c o m*/
    }
    logger.info("User deleted successfully, User details=" + u);
}

From source file:com.esales.model.CategoriaModel.java

public Categoria findById(int id) {
    //Cria lista de objetos
    Categoria objCategoria = null;// ww  w . ja  v a 2s  . co m
    //Abre um sesso
    Session objSession = this.objSessionFactory.openSession();

    try {
        objCategoria = (Categoria) objSession.load(Categoria.class, id);
    } catch (ObjectNotFoundException e) {
        return null;
    }
    //Fecha a sesso
    //objSession.close();
    //Retorna objeto categoria
    return objCategoria;
}

From source file:com.esales.model.ModelDAO.java

public SystemUser findById(int id) {
    //Cria lista de objetos
    SystemUser objUsuario = null;/*ww w  .  j a  v  a 2 s . c  o  m*/
    //Abre um sesso
    Session objSession = this.objSessionFactory.openSession();

    try {
        objUsuario = (SystemUser) objSession.load(SystemUser.class, id);
    } catch (ObjectNotFoundException e) {
        return null;
    }
    //Retorna objeto Usuario
    return objUsuario;
}

From source file:com.esales.model.RacaModel.java

public Raca findById(int id) {
    //Cria lista de objetos
    Raca objRaca = null;/*ww w  .  j a  va 2  s  .c  o  m*/
    //Abre um sesso
    Session objSession = this.objSessionFactory.openSession();

    try {
        objRaca = (Raca) objSession.load(Raca.class, id);
    } catch (ObjectNotFoundException e) {
        return null;
    }
    //Fecha a sesso
    //objSession.close();
    //Retorna objeto categoria
    return objRaca;
}

From source file:com.esales.model.UsuarioModel.java

public Usuario findById(int id) {
    //Cria lista de objetos
    Usuario objUsuario = null;//from  ww  w  . j  av  a2  s.  c o  m
    //Abre um sesso
    Session objSession = this.objSessionFactory.openSession();

    try {
        objUsuario = (Usuario) objSession.load(Usuario.class, id);
    } catch (ObjectNotFoundException e) {
        return null;
    }
    //Retorna objeto Usuario
    return objUsuario;
}

From source file:com.esales.model.UsuarioTipoModel.java

public UsuarioTipo findById(int id) {
    //Cria lista de objetos
    UsuarioTipo objUsuario = null;/*w w w.  j a  va 2s .  c  om*/
    //Abre um sesso
    Session objSession = this.objSessionFactory.openSession();

    try {
        objUsuario = (UsuarioTipo) objSession.load(UsuarioTipo.class, id);
    } catch (ObjectNotFoundException e) {
        return null;
    }
    //Retorna objeto Usuario
    return objUsuario;
}

From source file:com.esteban.cmms.maven.model.Ciudades_Model.java

/**
 * //from   www .  ja  v  a  2s . co m
 * @param objid Elimina una ciudad con solo pasarle el Id del registro 
 * que se desesa eliminar
 */

public void deleteCiudad(int objid) {
    Transaction trns = null;
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        trns = session.beginTransaction();
        Ciudades obj = (Ciudades) session.load(Ciudades.class, new Integer(objid));
        session.delete(obj);
        session.getTransaction().commit();
    } catch (RuntimeException e) {
        if (trns != null) {
            trns.rollback();
        }
        e.printStackTrace();
    } finally {
        session.flush();
        session.close();
    }
}