【发布时间】:2020-02-21 13:27:14
【问题描述】:
我需要创建一个 jpa 自定义查询,使用几个表上的连接来获取记录。
这是我想要实现的目标:
- 根据几个参数对数据进行排序(在运行时决定)
- 使用 where 子句过滤(在运行时决定)
例子:
@Query(value="Select a.name,b.city,c.reason from user a join address b on a.id=b.id join test c on a.id=c.id
where whereClause1 and whereClause2 //where子句可以是单个也可以是多个
order by orderByClause1 asc/desc //在运行时决定使用哪个参数进行排序"
List findData(String whereClause1,String whereClause2,String orderByClause1)
我无法为其创建通用查询。
我也可以接受任何其他方式来解决这个问题。 谢谢!!!
【问题讨论】:
标签: mysql hibernate spring-boot spring-data-jpa