I am using currently Spring Data JPA and I would like to map an attribute
@Entity
public class Outer {
...
Map<String, List<String>> typesToCategories;
}
Let's assume I have a tables outer
and outer_type_category
. The first one is trivial: only column outer_id
is relevant from it
CREATE TABLE outer_types_categories (
id uuid NOT NULL,
outer_id uuid NOT NULL,
type character varying(128) NOT NULL,
category character varying(128) NOT NULL,
...
)
Which annotations should I use (if it is possible in general) to map this table to the map?
I have tried to use this
@ElementCollection
@CollectionTable(name = "outer_type_category", joinColumns = [JoinColumn(name = "outer_id")])
@MapKeyColumn(name = "type")
@Column(name = "category")
Map<String, List<String>> typesToCategories;
but in the end I see an exception:
Caused by: org.hibernate.MappingException: Could not determine type for: java.util.List, at table: outer_type_category, for columns: [org.hibernate.mapping.Column(category)]
Did I forget anything?