I have vehicle service that, among other has list of parts. Adding new service is not a problem, viewing of service is not a problem, but when I try to implement edit, it do
I was searching about another thing and just came across to this post, thought to share a practical and much simpler solution to this issue.
Sometimes being drowned in technologies don't let us think out of the box.
For this one, instead going through all the definitions of converters or formaters, we can simply convert objects set (In this case parts) to string or primitives set inside action method and then add it to the model.
Then inside template just simply check if the set contains any option value:
//In edit action:
Set selectedPartsLongSet = selectedParts.stream().map(Part::getId).collect(Collectors.toSet);
model.addAttribute("selectedPartsLongSet", selectedPartsLongSet);
In ui: