Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multimap in Hibernate

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

like image 441
vyom Avatar asked Jan 24 '09 11:01

vyom


1 Answers

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.

like image 61
Michael Borgwardt Avatar answered Oct 19 '22 14:10

Michael Borgwardt