Using VARCHAR or TEXT as default String mapping in OpenJPA

jpa, openjpa, postgresql

Solution

It seems that Hibernate supports this since 3.6: 6.5. Type Registry. Tracked by this JIRA issue: HHH-5138.

Problem

By default, OpenJPA's `postgres` dictionary generates `VARCHAR(255)` for `String` fields without stated length. Can it be set up to generate `VARCHAR` or `TEXT` instead for all such fields, so that I don't need to repeat `@Column(columnDefinition = "TEXT")` everywhere? Of course, if the length is given explicitly, e.g. `@Column(length = 128)`, the result should be `VARCHAR(128)`. For that matter, do any other JPA providers allow this?

Original source