spring data jpa 分页问题

hfzlmx 2014-12-16 12:51:00
项目中分页使用的JpaSpecificationExecutor接口的
Page<T> findAll(Specification<T> spec, Pageable pageable);

现在有个取最大值的查询
select userId, max(score) from exam where examId='1' group by examId, userId
或者
select exam.* from exam,(select userId, max(score) from exam where examId='1' group by examId, userId) as exam_temp where exam_temp.examId=exam.examId

对于Specification参数,不知道如何实现
Specification<T> specification = new Specification<T>(){
@Override
public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) {
//这里如何实现
}
});

请技术牛人帮忙解决,如有更好办法请告知。
...全文
270 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
a_king 2014-12-17
  • 打赏
  • 举报
回复
可以用分页插件
  • 打赏
  • 举报
回复
引用 3 楼 rui888 的回复:
你在浦东哪里
广兰路这边
tony4geek 2014-12-17
  • 打赏
  • 举报
回复
引用 1 楼 shijing266 的回复:
http://bbs.csdn.net/topics/390411386?page=1 看看这个,应该照着写没问题的
你在浦东哪里
  • 打赏
  • 举报
回复
http://bbs.csdn.net/topics/390411386?page=1 看看这个,应该照着写没问题的

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧