I need a collection that stores entries as key-value pairs (so I can look up values by a key), but I need one that allows multiple values to share the same key using hibernate
A map with multiple values for one key is known as a multimap - there's an implementation in the Apache commons library. Hibernate does not support this kind of collection directly, but it can be extended to do so relatively easily by implementing the UserCollectionType
interface. This blog article describes how to do it in detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With