use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember in project pyramus by otavanopisto.
the class CourseStaffMemberDAO method findByCourseAndStaffMember.
public CourseStaffMember findByCourseAndStaffMember(Course course, StaffMember staffMember) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CourseStaffMember> criteria = criteriaBuilder.createQuery(CourseStaffMember.class);
Root<CourseStaffMember> root = criteria.from(CourseStaffMember.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(CourseStaffMember_.course), course), criteriaBuilder.equal(root.get(CourseStaffMember_.staffMember), staffMember)));
return getSingleResult(entityManager.createQuery(criteria));
}
Aggregations