DISTINCT 在 JPA 中与哪一列一起使用,是否可以更改它?
这是一个使用 DISTINCT 的 JPA 查询示例:
select DISTINCT c from Customer c
这没有多大意义 - distinct 基于哪一列?是否因为找不到而在实体上指定为注解?
我想指定要区分的列,例如:
select DISTINCT(c.name) c from Customer c
我正在使用 MySQL 和 Hibernate。
最佳答案
你很接近。
select DISTINCT(c.name) from Customer c
关于java - 使用 JPA 和 Hibernate 时 DISTINCT 是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1346181/