I have the following code, where Class has a relationship with Student through students property.
Root<SchoolClass> root = criteria.from(SchoolClass.class);
Join<SchoolClass, Student> classStudentMapping = root.join("students");
This is working fine, no problem. But now I want to join to another entity which has no relationship with Classes but only with student. say Address... How I can join using criteria builder?
Simply, start the secon join from classStudentMapping
:
Join<Student, Address> = classStudentMapping.join("address");
This is possible because the interface involved in this process, From<Z,X>
, extends Path<X>
, therefore classStudentMapping
is a Path<Student>
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.