You can store Map<K, List<V>>
as Set<Map.Entry<K, List<V>>>
this way.
@Entity
public class Entity {
//...
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "entity_id")
private Set<MultiValueMapEntry> multiValueMap = new ArrayList<>();
}
@Entity
public class MultiValueMapEntry {
private String key;
@ElementCollection
private List<String> values = new ArrayList<String>();
}
In Entity class use @OneToMany Unidirectional relation for every Map.Entry<K, List<V>>
and use @ElementCollection
for List<V>
of every map entry.
To learn about @OneToMany Unidirectional see here and
to learn about @ElementCollection see here
And for Set<Map.Entry<K, List<V>>>
to Map<K, List<V>>
converstion see here