Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

444
Views
¿Cómo obtener todos los datos en la tabla con hibernate?
public Service getServiceData(){ return (Service)ServiceDaoImpl.getSession().get(Service.class, new Integer(1)); }

El método get es obtener uno. Quiero obtener todos los datos para la página jsp.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Con Hibernate 5 createCriteria está en desuso, use algo como esto

 private static <T> List<T> loadAllData(Class<T> type, Session session) { CriteriaBuilder builder = session.getCriteriaBuilder(); CriteriaQuery<T> criteria = builder.createQuery(type); criteria.from(type); List<T> data = session.createQuery(criteria).getResultList(); return data; }

uso

 Session session = HibernateUtils.getSession(); List<User> users = loadAllData(User.class, session);
about 4 years ago · Santiago Trujillo Report

0

Pruebe el siguiente código y reemplace Entity con su clase Entity

 @SuppressWarnings("unchecked") public List<Entity> getAlldata(){ try { return sessionFactory.getCurrentSession().createCriteria(Entity.class).list(); } catch (Exception e) { return new ArrayList<>(); } }
about 4 years ago · Santiago Trujillo Report

0

Intente lo siguiente para obtener todas las filas de la tabla

 @SuppressWarnings("unchecked") public List<Service> Service getServiceData() { return ServiceDaoImpl.getSession().createQuery("from Service").list(); }
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!