Search code examples
jakarta-eejdbcjpa-2.0glassfish-3jta

Changing a column type from varchar to CLOB with JPA


I'm trying to change the data type of a column using the JPA annotation:

@Column(columnDefinition="CLOB")
private String description;

Whenever this entity is persisted, a VARCHAR value is attempted to be stored, which is not long enough. I couldn't find any documentation on the @Column annotation specific to CLOB except one that defined a column = "CLOB NOT NULL". I want NULL values to be allowed. Is "CLOB" not the correct column definition here?

I'm using EclipseLink to persist to a JavaDB database.


Solution

  • Use the @Lob annotation on the field. API doc: http://docs.oracle.com/javaee/5/api/javax/persistence/Lob.html