so I want to return Set from a entity in database. So I have crudRepository and first I return optional Knight from repo looking by id and then I want to get his set of quests from Optionlal
public Set<Quest> getAllUserStories(Long id)
{
Optional<Knight> knight = knightRepository.findById(id);
Set<Quest>set = knight.stream().map(k->k.getQuests()).collect(Collectors.toSet());
return listToReturn;
}
it almost works but its set of sets and I dont know how can I collet something without making it set? Other question is what if that set of quests is empty, would collect work on null?