public List<Project> getProjectsByNameAndId(final String projectName, final long id) { CriteriaQuery<Project> q = criteriaBuilder.createQuery(Project.class); Root<Project> p = q.from(Project.class); q.where( criteriaBuilder.and( criteriaBuilder.equal(p.get(Project_.name), projectName), criteriaBuilder.notEqual(p.get(Project_.id), id))); return crudService.createQuery(q).getResultList(); }
@SuppressWarnings("CPD-START") public List<Scenario> getScenariosByName(final long projectId, final String scenarioName) { CriteriaQuery<Scenario> q = criteriaBuilder.createQuery(Scenario.class); Root<Scenario> s = q.from(Scenario.class); q.where( criteriaBuilder.and( criteriaBuilder.equal(s.get(Scenario_.name), scenarioName), criteriaBuilder.equal(s.get(Scenario_.project).get(Project_.id), projectId))); return crudService.createQuery(q).getResultList(); }
public List<Project> getProjectsWithName(final String projectName) { CriteriaQuery<Project> q = criteriaBuilder.createQuery(Project.class); Root<Project> p = q.from(Project.class); q.where(criteriaBuilder.equal(p.get(Project_.name), projectName)); return crudService.createQuery(q).getResultList(); }
public List<Project> getAllSortedAscendingByName() { CriteriaQuery<Project> q = criteriaBuilder.createQuery(Project.class); Root<Project> p = q.from(Project.class); q.orderBy(criteriaBuilder.asc(p.get(Project_.name))); return crudService.createQuery(q).getResultList(); }