Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Derby "A truncation error was encountered trying to shrink CLOB '<stream-value>' to length 255"

I have a column definition in my JPA entity.

@Lob
String message;

I have following error when I try to persist my entity with some message.

Caused by: java.sql.SQLException: Java exception: 'A truncation error was encountered trying to shrink CLOB '' to length 255.: org.apache.derby.iapi.services.io.DerbyIOException'.

Caused by: org.apache.derby.iapi.services.io.DerbyIOException: A truncation error was encountered trying to shrink CLOB '' to length 255.

I'm using Hibernate 4.2.15.Final with Apache Derby 10.10.2 and schema generation during testing. It looks like the length of the column is limited to 255. How to overcome this error?

like image 267
zbig Avatar asked Sep 17 '14 08:09

zbig


1 Answers

The Derby dialect in Hibernate generates column definition with limited legth:

message clob(255)

You may want to override this behaviour and set your own length or leave default length. You may use

@Column(columnDefinition="clob")
@Lob
String message;

Remember that in derby

A CLOB without a specified length is defaulted to two gigabytes (2,147,483,647)

like image 196
zbig Avatar answered Sep 30 '22 15:09

zbig