您可以在此处查看 Spring Data JPA 和 Spring Data MongoDB 之间 distinct 的使用差异:
@Before
public void setUp() {
this.dave = customers.save(new Customer("Dave", "Matthews"));
this.carter2 = customers.save(new Customer("Carter", "Z"));
this.carter = customers.save(new Customer("Carter", "Beauford"));
}
@Test
public void distinctProjectsEntityIntoInterface() {
Collection<CustomerProjection> result = customers.findAllProjectedDistinctBy();
assertThat(result, hasSize(2));
}
春季数据jpa中的不同
@Before
public void setUp() {
customers.deleteAll();
this.dave = customers.save(new Customer("Dave", "Matthews"));
this.carter2 = customers.save(new Customer("Carter", "Z"));
this.carter = customers.save(new Customer("Carter", "Beauford"));
}
@Test
public void distinctProjectsEntityIntoInterface() {
Collection<CustomerProjection> result = customers.findAllProjectedDistinctBy();
assertThat(result, hasSize(3));
}
在春季数据MongoDB中不同
在哪里
interface CustomerProjection {
String getFirstname();
}