小编Jas*_*son的帖子

春天的JPA预测可以收藏吗?

我有一个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.投影必须具有扁平结构,即它们不像真实实体那样支持集合吗?

projection spring-data-jpa

10
推荐指数
1
解决办法
1215
查看次数

标签 统计

projection ×1

spring-data-jpa ×1