This is part of my model:
@Entity public class Entry { @Id @GeneratedValue private long identifier; @ElementCollection @Column(nullable = false) private Map<String, String> titles; @ElementCollection @Column(nullable = false) @Lob private Map<String, String> contents;
I use the @Lob annotation because the value of the "contents" of the map can be large. Note that I don’t care how the “content” key of the map maps to the database. I simply could not find a way to indicate that the @Lob annotation should only apply to the value of the map.
While Entry.titles maps to the database without problems, Entry.contents does not. There is no database table, and MySQL / Hibernate complains that:
Unsuccessful: create table myblog.Entry_contents (Entry_identifier bigint not null, contents longtext not null, contents_KEY longtext, primary key (Entry_identifier, contents_KEY)) type=InnoDB BLOB/TEXT column 'contents_KEY' used in key specification without a key length
Any ideas appreciated!
source share