BeanUtils.copyProperties
每次遇到集合时都会失败。
@Transactional
public void createFreshAmendmentsForRestructureEvent(CcrRestructureEventMetadata restructureEventMetadata, String token, String racf) {
List<Contract> contracts = getActiveContractsByRestructureEvent(restructureEventMetadata);
if (isEmpty(contracts)) {
log.info("No existing contract amendments found under the given restructure event [{}]...", restructureEventMetadata.getId());
} else {
// Create new Contract submission record
contracts
.forEach(c -> {
Contract newContract = new Contract();
BeanUtils.copyProperties(c, newContract);
newContract.setRestructureEvent(restructureEventMetadata.getRestructureEvent());
newContract.setCreditStatus(restructureEventMetadata.getCreditStatus());
addNewContract(newContract, new java.util.Date(), token, racf);
});
// Close existing contracts
contracts.stream()
.peek(c -> c.setEffectiveToDt(new java.util.Date()))
.forEach(contractRepository::save);
}
}
例外情况:
Caused by: org.hibernate.HibernateException: Found shared references to a collection: com.rbs.zambezi.ccr.domain.Contract.contractPortfolioCodes
这是你的答案 Contract
具有集合引用的实体节:
...
@OneToMany( fetch=FetchType.EAGER)
@JoinColumn(name="CONTRACT_ID" )
public Set<ContractPortfolioCode> contractPortfolioCodes;
...
有人能帮忙解决这个问题吗?
暂无答案!
目前还没有任何答案,快来回答吧!