域名1->
(ContractTerms)
private BigDecimal id;
private ProgramDetails programDetails;
Domain2→
(ProgramDetails)
private BigDecimal id;
private ProcessType processTypeId;
我想把它按processTypeId分组使用detachedcriteria我正在从DB中获取列表但现在我希望它按processTypeId分组
termValueForExtention.stream().collect(grouppingBy(ContractTerms::getProgramDetails));
然后要访问嵌套在另一个属性中的属性,您需要将代码中的方法引用替换为以下lambda表达式:BigDecimal所在的位置为
Map<BigDecimal, List<ContractTerms>>
ProcessTypeId
List<ContractTerms> termValueForExtention = // initializing the list of ContractTerms
Map<BigDecimal, List<ContractTerms>> result = termValueForExtention.stream()
.collect(Collectors.groupingBy(
contractTerms -> contractTerms.getProgramDetails().getProcessTypeId()
));