如何在spring jpa中根据用户输入生成Dynamic select and group by clause并返回一个List<UserType>?

问题描述 投票:0回答:0

我有这样的要求: 用户将传递列表作为输入, 通过使用用户输入,我想动态构建查询(SELECT 和 GROUP BY 子句)并从数据库中检索数据。 例如:如果用户通过

List<String> userInput =[studId,studName,stud.addr.city,stud.addr.country,stud.qualification.higQual,stud.qualfication.passYear]

Then query should be like : SELECT studId,studName,stud.addr.city,stud.addr.country,stud.qualification.higQual,stud.qualfication.passYear FROM Student stud GROUP BY studId,studName,stud.addr.city,stud.addr.country,stud.qualification.higQual,stud.qualfication.passYear

通过加入实体在类级别维护关系。 如何使用 spring JPA 实现上述查询并在列表中检索结果?

List<Student> students = repo.findStudents() // response should be List<Student>
java hibernate jpa spring-data-jpa spring-data
© www.soinside.com 2019 - 2024. All rights reserved.