Rahul Mittal
Rahul Mittal

Reputation: 83

Value too long for column limiting by varchar(255) constraint while posting data via Rest API

I am having data in JSON File, While populating that data in h2 database, getting below error : Value too long for column "COMMENT VARCHAR(255)"

As in my json data AUTHORS is exceeding the limit of 255 characters.

So what should I do to accommodate more than 255 characters in database passed as string. String comment; and in comments passing more than 255 char.

Upvotes: 0

Views: 2132

Answers (1)

Rahul Mittal
Rahul Mittal

Reputation: 83

Instead of simply using String datatype, I annotated with @LOB to all the variables whose length of characters might exceeds 255.

Lob signifies that the annotated field should be represented as BLOB (binary data) in the DataBase. You can annotate any Serializable data type with this annotation. In JPA, upon persisting (retrieval) the field content will be serialized (deserialized) using standard Java serialization.

Upvotes: 3

Related Questions