有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java hsqldb hibernate persist@Lob

我试图将一个长字符串持久化到数据库(异常的stacktrace),我们使用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

有什么建议吗? 谢谢


共 (1) 个答案

  1. # 1 楼答案

    我已经迁移到2.3.1,在同一个地方出现错误,但有更具体的解释:

    HsqlException:数据异常:字符串数据,右截断 然后添加注释@列:

    @Lob
    @Column(length=20971520)
    private String someBigMessage;
    

    然后迁移回2.2.9,它就可以工作了