MapKeyEnumerated 到 String
MapKeyEnumerated to String
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "entity_identifier")
@MapKeyEnumerated(EnumType.STRING)
@MapKey(name = "type")
@Column(name = "identifier")
val identifiers: MutableMap<IdentifierType, String> = mutableMapOf()
抛出这个
Caused by: org.hibernate.AnnotationException: Associated class not found: java.lang.String
表格很简单
create table entity(
id serial primary key
);
create table entity_identifier(
entity_id bigint references entity ( id ),
identifier text,
type text,
);
有什么方法可以让这个 Map
工作吗?
看来需要用@MapKeyColumn
,不知道为什么
@ElementCollection( fetch = FetchType.EAGER)
@CollectionTable(name="entity_identifier")
@MapKeyColumn(name="type")
@MapKeyEnumerated(EnumType.STRING)
@Column(name = "identifier")
val identifiers: MutableMap<IdentifierType, String> = mutableMapOf()
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "entity_identifier")
@MapKeyEnumerated(EnumType.STRING)
@MapKey(name = "type")
@Column(name = "identifier")
val identifiers: MutableMap<IdentifierType, String> = mutableMapOf()
抛出这个
Caused by: org.hibernate.AnnotationException: Associated class not found: java.lang.String
表格很简单
create table entity(
id serial primary key
);
create table entity_identifier(
entity_id bigint references entity ( id ),
identifier text,
type text,
);
有什么方法可以让这个 Map
工作吗?
看来需要用@MapKeyColumn
,不知道为什么
@ElementCollection( fetch = FetchType.EAGER)
@CollectionTable(name="entity_identifier")
@MapKeyColumn(name="type")
@MapKeyEnumerated(EnumType.STRING)
@Column(name = "identifier")
val identifiers: MutableMap<IdentifierType, String> = mutableMapOf()