public List<Sucursales> sucursalesporLocalidad(String loco) {
    Session session = null;
    List<Sucursales> suc = null;

    try {
      session = HibernateUtil.getSessionFactory().openSession();
      Query query = session.createQuery("from Sucursales where localidades.idLocalidad=" + loco);
      suc = (List<Sucursales>) query.list();
    } catch (HibernateException e) {
      System.out.println(e.getMessage());
    } finally {
      if (session != null) {
        session.close();
      }
    }
    return suc;
  }
  public Sucursales buscarSucursal(String id) {
    Session session = null;
    Sucursales suc = null;

    try {
      session = HibernateUtil.getSessionFactory().openSession();
      Query query = session.createQuery("from Sucursales where idSucursal=" + id);
      suc = (Sucursales) query.uniqueResult();
    } catch (HibernateException e) {
      System.out.println(e.getMessage());
    } finally {
      if (session != null) {
        session.close();
      }
    }
    return suc;
  }
 @Override
 public List<Color> filtarTipoDos() {
   Session session = null;
   List<Color> lista = null;
   try {
     session = HibernateUtil.getSessionFactory().openSession();
     Query query = session.createQuery("FROM Color");
     lista = (List<Color>) query.list();
   } catch (HibernateException e) {
     System.out.println(e.getMessage());
   } finally {
     if (session != null) {
       session.close();
     }
   }
   return lista;
 }
  @Override
  public List<Sucursales> mostraSucursales() {
    Session session = null;
    List<Sucursales> suc = null;

    try {
      session = HibernateUtil.getSessionFactory().openSession();
      Query query = session.createQuery("from Surcursales");
      suc = (List<Sucursales>) query.list();
    } catch (HibernateException e) {
      System.out.println(e.getMessage());
    } finally {
      if (session != null) {
        session.close();
      }
    }
    return suc;
  }
 @Override
 public void modificarTarjetaNaranja(TarjetaNaranja tarjetaNaranja) throws Exception {
   Session session = null;
   try {
     session = HibernateUtil.getSessionFactory().openSession();
     session.beginTransaction();
     session.update(tarjetaNaranja);
     session.getTransaction().commit();
   } catch (ConstraintViolationException e) {
     session.getTransaction().rollback();
     throw new Exception(e.getSQLException());
   } catch (HibernateException e) {
     session.getTransaction().rollback();
     throw new Exception(e);
   } finally {
     if (session != null) {
       session.close();
     }
   }
 }
 @Override
 public Long insertarFacturaA(GenFacturaA genFacturaA) throws Exception {
   Session session = null;
   Long id = null;
   try {
     session = HibernateUtil.getSessionFactory().openSession();
     session.beginTransaction();
     id = (Long) session.save(genFacturaA);
     session.getTransaction().commit();
   } catch (ConstraintViolationException e) {
     session.getTransaction().rollback();
     throw new Exception(e.getSQLException());
   } catch (HibernateException e) {
     session.getTransaction().rollback();
     throw new Exception(e);
   } finally {
     if (session != null) {
       session.close();
     }
   }
   return id;
 }