【发布时间】:2023-01-20 22:16:53
【问题描述】:
假设我有一个带有 Clob 列的实体条目,例如:
@Entity
public class Entry {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_GENERATOR")
private Long id;
@Lob
@Column(name = "value")
private String data;
...
在数据库中,我们有一个现有的条目行,其中 VALUE 是一个用 Oracle 的 EMPTY_CLOB() 函数初始化的 clob。 我需要将现有实体克隆到一个新实体,但是在查询并设置一个空字符串以从 Java 端模拟 EMPTY_CLOB() 之后,Oracle 显示一个(空)值而不是一个空的 Clob。 当使用 hibernate 作为 JPA 实现时。
使用 JPA 保存实体 2 后的预期结果:
SELECT * FROM ENTRY
ID VALUE
1 <------------ Returning an empty CLOB here
2 (null)
实际行为
SELECT * FROM ENTRY
ID VALUE
1 <------------ Returning an empty CLOB here
2 <------------ Returning an empty CLOB here
【问题讨论】:
-
抱歉,帖子中有错误,所需的行为是:SELECT * FROM ENTRY ID VALUE 1 <------------ Returning an empty CLOB here 2 <---------- -- 在这里返回一个空的 CLOB