java - why my criteriaQuery.select method is wrong in spring data jpa -
i writing spring data jpa using specification. idea give me error(red line):
'select(javax.persistence.criteria.selection<? extends capture<?>>)' in 'javax.persistence.criteria.criteriaquery' cannot applied '(javax.persistence.criteria.root<cn.lvxg.po.classroom>)'
here code. please me!
the root subclass of selection. why code wrong?
i suffering problem.
specification<student> specification = new specification<student>() { public predicate topredicate(root<student> root,// criteriaquery<?> criteriaquery, criteriabuilder criteriabuilder) { root<classroom> classroomroot = criteriaquery.from(classroom.class); root<student> studentroot = criteriaquery.from(student.class); criteriaquery.select(classroomroot) .distinct(true) .where(criteriabuilder.equal(studentroot,classroomroot.get("id"))); return criteriaquery.getrestriction();; } }; pageable pageable = new pagerequest(0, 5); page<student> studentspage = jpaspecificationrepository.findall(specification, pageable);
should 1 root in query.
Comments
Post a Comment