public class ValidateClaimDataEntity{
...
@OneToMany(mappedBy = "claimDataEntity")
private List<ValidateEventDataEntity> eventDataEntityList;
}
when I do
function(ValidateClaimDataEntity claimDataEntity){
claimDataEntity
.getEventDataEntityList().parallelStream()....
}
I got null point exception, and I debug got claimDataEntity .getEventDataEntityList() is null But actually this claimDataEntity have related event data in db
and I do it in UT like :
claimDataEntityRepository.findById(32L).get().getEventDataEntityList().parallelStream().forEach(eventDataEntity -> {
log.info(eventDataEntity.getValidateEventDataId());
});
It do log event data
So, why the function claimData get eventList as null???
--------------------v1----------------------------------------
I found it might not be the problem of stream, Actually I do a save before the iterator
public ValidateClaimResponse bc(ValidateClaimRequest claimRequest) {
//claim
ValidateClaimDataEntity claimDataEntity = new ValidateClaimDataEntity(claimRequest);
claimDataEntityRepository.save(claimDataEntity);
claimRequest.getEventRequestList()
.forEach(eventRequest -> {
...
//event
ValidateEventDataEntity eventDataEntity = new ValidateEventDataEntity(eventRequest);
eventDataEntity.setValidateClaimDataId(claimDataEntity.getValidateClaimDataId());
eventDataEntityRepository.save(eventDataEntity);
});
System.out.println(claimDataEntity.getEventDataEntityList() == null ? "null" : claimDataEntity.getEventDataEntityList() );
ValidateClaimDataEntity claimDataEntity2 = claimDataEntityRepository.findById(claimDataEntity.getValidateClaimDataId()).get();
System.out.println(claimDataEntity2.getEventDataEntityList() == null ? "null2" : claimDataEntity2.getEventDataEntityList());
And I got both null of eventList