我正在尝试将长字符串持久化到数据库(异常的堆栈跟踪),我们使用HSQLDB(2.2.9)进行测试,使用Postgre进行运行。
1)我注释了
字段@Lob
private String someBigMessage;
2)写了迁移DDL脚本(flyway但不管)
..., some_big_message text, ...
3)它迁移好了,但是当我执行JUnit测试时,使用hsqldb我得到了这个:
org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.GenericJDBCException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
...
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute statement
...
Caused by: org.hibernate.exception.GenericJDBCException: could not execute statement
...
Caused by: java.sql.SQLException: java.lang.RuntimeException: unsupported internal operation: Session java.lang.RuntimeException: unsupported internal operation: Session
...
Caused by: org.hsqldb.HsqlException: java.lang.RuntimeException: unsupported internal operation: Session
有什么建议吗? 感谢。
答案 0 :(得分:4)
我已迁移到2.3.1,在同一个地方出错,但有更具体的解释:
HsqlException:数据异常:字符串数据,右截断 然后添加注释@Column:
@Lob
@Column(length=20971520)
private String someBigMessage;
然后迁移回2.2.9并且它有效!