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?
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With