This is part of my model:
Code:
@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;
// Getters and setters, other fields and methods
}
I use the @Lob annotation because the value of map "contents" can be large. Note that I do not care about how the key of map "contents" is mapped to the database. I just couldn't find a way to specify that the @Lob annotation should be applied only to the value of the map.
While Entry.titles is mapped to the database without problems, Entry.contents is not. No database table is created and MySQL/Hibernate complains that:
Quote:
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 are appreciated!