I need to persist a member with the type Map<Item, Set<Item>>, using JPA2 annotations.
The relation is many to many and Item objects are entities.
Should I create a separate intermediary Entity holding Set<Item> or is a direct mapping possible?
Please advise if some context is missing.
JPA doesn’t support nested collection relationships (
ListofLists,MapofSets, etc). Here is the relevant section of the specification aboutMap:So yes, use an entity holding the
Set<Item>and then map your relation asMap<Item, MyHolder>.References