DataIntegrityViolationException during tests ("Value too long for column") with H2

Viewed 85

I'm simply using a JpaRepository to save objects on a database. A new (quite long) field was added and now some tests are failing with

org.springframework.dao.DataIntegrityViolationException: could not execute statement; 
    SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
    at com.Tests.test(Tests.java:43)
Caused by: org.hibernate.exception.DataException: could not execute statement
    at com.Tests.test(Tests.java:43)
  Caused by: org.h2.jdbc.JdbcSQLDataException: 
  Value too long for column "PAYMENT_TEMPLATES VARCHAR(255)": "... (338)"; SQL statement:

There are no issues in the actual database, but on H2 the default limit for varchars is 255 characters. Is there a way to set it only in test classes/configuration, instead of explicitly using the @Column annotation, like shown here?

0 Answers
Related