在我的Spring Boot Maven项目中,我添加了 QueryDSL + SpringData + JPA 支持。
添加了两个存储库
StudentRespository
公共接口StudentRespository扩展了JpaRepository,QueryDslPredicateExecutor {
}
课程库
公共接口CourseRepository扩展了JpaRepository,QueryDslPredicateExecutor {
}
在JPA模型课程中,学生和课程之间的映射是通过OneToMany关系定义的(在我的情况下,学生包含课程列表)
表结构为
我只想使用URL查询数据。
当前
我可以让所有学生 http://localhost:9000/students
能够通过 http://localhost:9000/students/1
能够通过过滤器获得学生 http://localhost:9000/students?Name=John
能够通过以下方式获得特定学生的课程 http://localhost:9000/students/1/courses
现在
我想在该学生正在接受的课程上应用过滤器。 表示 http://localhost:9000/students/1/courses?Name=English
但是,它无法正常工作并且返回与该学生相关的所有课程。而我只希望在“名称”字段中(其中包括这些学生课程)包含“英语”的课程。
有人可以帮助我实现此功能吗?
谢谢。