I am using 5.4.2 Hibernate version to query a list from DB. I can list the query successfully but unfortunately even I am not using getSingleResult(), I always get the latest query result from DB instead of getting all of them. Could you please help me to fix that issue ?

You can find the required information below.

    CriteriaBuilder criteriaBuilder = getSession().getCriteriaBuilder();
    CriteriaQuery<Project> criteriaQuery = 
    criteriaBuilder.createQuery(Project.class);
    Root<Project> projectTableRoot =criteriaQuery.from(Project.class);
    projectTableRoot.alias(EMPLOYEE).alias(ORDER);
    Join<Project, Employee> projectEmployeeTableJoin = projectTableRoot.join(EMPLOYEE);
    Join<Project, OrderE> projectTableOrderEntryJoin = projectTableRoot.join(ORDER);

    Predicate projectPredicate = criteriaBuilder.equal(projectTableRoot.get(DELETED), false);
    projectPredicate = criteriaBuilder.and(projectPredicate, criteriaBuilder.equal(projectTableRoot.get(ARGE_PROJECT), argeProject));

  criteriaQuery.select(projectTableRoot).where(criteriaBuilder.and(projectPredicate));
    List<ProjectTable> resultList = getSession().createQuery(criteriaQuery).getResultList();

0 Answers