我有一个Customer实体,我只想从中选择几个字段及其关联的CustomerAddresses.我已经定义了一个Spring Data JPA投影接口,如下所示:
public interface CustomerWithAddresses {
Integer getId();
String getFirstName();
String getLastName();
String getBrandCode();
String getCustomerNumber();
Set<CustomerAddress> getCustomerAddresses();
}
Run Code Online (Sandbox Code Playgroud)
但是从我的Repository方法:
CustomerWithAddresses findCustomerWithAddressesById(@Param("id") Integer id);
Run Code Online (Sandbox Code Playgroud)
我一直为拥有多个CustomerAddresses的客户获取NonUniqueResultException.投影必须具有扁平结构,即它们不像真实实体那样支持集合吗?