我试图将一个长字符串保存到数据库(异常的堆栈跟踪),我们使用 HSQLDB (2.2.9) 进行测试,使用 Postgre 进行运行时。
1)我注释字段如
@Lob
private String someBigMessage;
2)编写迁移DDL脚本(flyway但无所谓)
..., some_big_message text, ...
3)它迁移正常,但是当我执行使用 hsqldb 的 JUnit 测试时,我得到以下结果:
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
有什么建议吗? 谢谢。
最佳答案
我已迁移到 2.3.1,在同一位置出现错误,但有更具体的解释:
HsqlException:数据异常:字符串数据,右截断 然后添加注解@Column:
@Lob
@Column(length=20971520)
private String someBigMessage;
然后迁移回 2.2.9,它就可以工作了!
关于java - hsqldb hibernate 持久化@Lob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25246451/