示例#1
0
 public boolean update(cl.sgg.edm.Proveedor a) throws Exception {
   Session session = NewHibernateUtil.getSessionFactory().openSession();
   session.beginTransaction();
   try {
     session.update(a);
     session.getTransaction().commit();
     session.close();
     return true;
   } catch (Exception e) {
     session.getTransaction().rollback();
     session.close();
     System.err.println(e.getMessage());
     throw e;
   }
 }
示例#2
0
  public List<cl.sgg.edm.Proveedor> getList() throws Exception {

    Session session = NewHibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    try {
      return (List<cl.sgg.edm.Proveedor>) session.createCriteria(cl.sgg.edm.Proveedor.class).list();
    } catch (Exception e) {
      session.getTransaction().rollback();
      session.close();
      System.err.println(e.getMessage());
      throw e;
    } finally {
      session.close();
    }
  }
示例#3
0
  public boolean add(cl.sgg.edm.Proveedor a) throws Exception {
    Session sessionA = NewHibernateUtil.getSessionFactory().openSession();
    sessionA.beginTransaction();
    try {
      sessionA.save(a);
      sessionA.getTransaction().commit();
      sessionA.close();
      return true;
    } catch (Exception e) {
      sessionA.getTransaction().rollback();
      sessionA.close();
      System.err.println(e.getMessage());

      throw new Exception("error en ProveedorDAO " + e.getMessage());
    }
  }
示例#4
0
  public cl.sgg.edm.Proveedor getProveedorByNombre(String nombre) throws Exception {
    Session session = NewHibernateUtil.getSessionFactory().openSession();
    try {
      session.beginTransaction();

      cl.sgg.edm.Proveedor tmp =
          (cl.sgg.edm.Proveedor)
              session
                  .createCriteria(cl.sgg.edm.Proveedor.class)
                  .add(Restrictions.eq("proveedorNombre", nombre))
                  .uniqueResult();

      session.close();
      return tmp;

    } catch (Exception e) {
      System.err.print(e.getMessage());
      session.close();
      throw e;
    }
  }