Map of strings can't handle more than varchar(255)

hibernate, java, jpa

Solution

I think you are using `varchar(255)`. Use a `text` column instead of `varchar(255)`.

In PostgreSQL always use text (unless of course there is a real length constraint).

Problem

Once total length of Map String(s) is greater than 255, JPA fails committing transaction. I'm using JPA 2.0 with Play 2 Framework. ``` @ElementCollection private Map<EmailNotificationType, String> mailContents = new HashMap<>(); ``` I tried @Column(length = 2048) @Lob @MapKeyColumn(length = 2048) I would like to persist as much as it's possible since its size is dynamic.

Original source