I have an entity with the following attribute
@Lob
@NotNull
private String myContent;
Now, in my production setup I use a CLOB
for representation in the database since the content can be several thousands of chars. However, for unit tests an in-memory HSQLDB is used. During the unit test I get this error
Caused by: org.hsqldb.HsqlException: data exception: string data, right truncation
at org.hsqldb.error.Error.error(Unknown Source)
As far as my research revealed, the reason should be that DBUnit creates a 255 char column for the string, automatically. And in my case it is not long enough for the content I insert. So, what could I do about this?
Try something like this:
@Column(columnDefinition = "VARCHAR", length = 65535)
@Lob
@NotNull
private String myContent;
That should cause a larger column to be created.