Search code examples
hibernatehsqldb

data exception: string data, right truncation error


I am upgrading hibernate version from 5.1.17 to 5.4.11. I am getting this error java.sql.sqldataexception data exception: string data, right truncation; table:tablename colum: columnname.

When I check it in database, this column is declared as VARCHAR2(4000 BYTE). I am getting this while running a test case which has data in a file. If I reduce the data related to this column then it is working.

It is old audit table. How and what changes I have to do on this column?

We have custom HSQLDialect class and I tried to register column type as

registerColumnType(Types.VARCHAR, "clob/varchar2/nvarchar" ); but I am getting user lacks privilege or object not found:

Can someone explain why it is failing after hibernate upgrade only (It was working fine with earlier version) and how to fix it?

Hibernate version: 5.4.11 HSQLDB version: 2.3.3 hibernate-search-orm: 5.11.5.Final lucene.version: 5.5.5


Solution

  • It is a hibernate issue as per https://hibernate.atlassian.net/browse/HHH-13886#icft=HHH-13886

    my column is defined as

    @Column(columnDefinition = "VARCHAR(4000)") private int caseNumber;

    it should be changed as

    @Column(length = 4000) private int caseNumber;

    This is change required only for Entities which are marked as @Audited.

    Now, my test case is working fine.

    see this for more info: https://hibernate.atlassian.net/secure/ReleaseNote.jspa?version=31818&styleName=Html&projectId=10031