【发布时间】:2020-08-07 05:10:00
【问题描述】:
我有一个 SQL 表:
@Table(name = "population_table")
public class Population {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String country;
private String state;
private String area;
private String population;
}
我想得到一个计数,按国家和州分组,输出类是计数列表:
private static class Count {
private String country;
private String state;
private long count;
}
我知道查询是
SELECT country, state, Count(*)
FROM population_table
GROUP BY country, state
但我想使用 JPA 规范来做到这一点。如何在 Spring Boot 中使用 JPA 规范来实现这一点?
【问题讨论】:
-
“我想使用规范执行此操作”是什么意思?
-
@NitishKumar 我的意思是 JPA 规范
标签: java sql sql-server spring-boot jpa