This is a problem I keep on running into:
I would like to have hibernate manage a single table that represents a collection of collections. For example:
- a Map of Maps
- List of Sets
- Map of Lists
Example, I would like to be able to represent this:
class OwningClass { Long entityId; Map<String, List<Element>> mapOfLists; } class Element { String data_1; boolean data_2; }
as a single table:
OWNER (Foreign key to the owner of this element) MAP_KEY (varchar(30) ) LIST_INDEX (int) ELEMENT_DATA_1 (varchar(1020) ELEMENT_DATA_2 (bit)
It doesn't seem possible without a custom hibernate code, which I don't mind. But I was hoping someone had some guidance on what that custom code should look like.
- Should I extend AbstractPersistentCollection?
- CompositeUserType?
Its possible to manage if multiple tables are o.k. but obviously that is lame from the db perspective.