I have a List like
@OneToMany
private List<Personal> personal;
Later on I want to filter results
List<Integer> ist = personal.stream().map(p -> p.getPnr()).collect(Collectors.toList());
But I always get an empty list. When I create an old school for-loop, things work as expected.
I added fetch=FETCH_TYPE.EAGER
to the @OneToMany
annotation, but it didn't fix the problem.
The debugger says, at runtime, 'personal' is a 'indirect list'. Is this the problem? And what can I do to fix it?
Code that work fine
List<Integer> ist = new ArrayList<>();
for (Personal p : personal)
ist.add(p.getPnr());