Reputation: 631
Is there a way to create a hibernate mapping where you have a Map of Bags or Sets or some type of collection?
For instance, maybe I have an inventory of parts and I want to pull them into a Map like so:
Map<PartType, List<Part>> inventory;
So PartType which might be a class or just a String is the map key.
Thanks for the input!
Upvotes: 3
Views: 1044
Reputation: 1158
No you can't, you need to create an intermediate class that contains the List. Your map will become :
Map<PartType, Parts> inventory;
And you need to create a new class with its own mapping :
public class Parts {
private List<Part> parts;
}
Upvotes: 2
Reputation: 121998
IMO it should be an Id
of PartType
pojo
<map name="mymap" cascade="all">
<key column="parttype_id"/>
.
.
.
</map>
Upvotes: 0