gpt4 book ai didi

java - hsqldb hibernate 持久化@Lob

转载 作者:行者123 更新时间:2023-12-01 18:28:16 24 4
gpt4 key购买 nike

我试图将一个长字符串保存到数据库(异常的堆栈跟踪),我们使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com