Could you please help me to persist map of strings with Hibernate?
Map values come from client and are random, so I don't want to store separate table for map's values
Exception
Caused by: org.hibernate.AnnotationException: Associated class not found: java.lang.String
Code
@Entity
public class UserConfig {
@Id
@SequenceGenerator(sequenceName = "CONFIG_SEQ", name = "ConfigSeq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ConfigSeq")
private Long id;
@ElementCollection(targetClass = String.class)
@CollectionTable(name = "MAP")
@MapKey(name="key")
@Column(name="value")
private Map<String, String> map;
Update
Could you please also explain how to persist Map<MyEnum, String>
, if MyEnum
is an unmapped class?