java - hsqldb hibernate 持久化@Lob

标签 java hibernate hibernate-mapping hsqldb

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

相关文章:

java - 为什么我的 for 循环在检查元音时在第一个元素之后退出? java

java - Hibernate Mapping 有必要吗?

java - Java hashMap 中的线程安全

java - java中的 volatile 和原子操作

java - Hibernate session 问题,新线程从 Grails Controller 启动

java - 注入(inject) Autowiring 的依赖项失败;嵌套异常是 org.springframework.beans.factory.BeanCreationException :

java - 通过 SSH Hibernate 远程 MySQL 数据库

java - Spring 与 Hibernate 集成获取重复记录

java - 寻找可变对象的 Hibernate UserType 方法的详细解释

java - Spring MVC Thymeleaf错误: array element type mismatch