Sunday, 8 September 2013

Persisting Empty Clob with JPA

Persisting Empty Clob with JPA

I am trying to persist empty clob (read not null) using JPA (Hibernate)
using the following method
public Long createEmptyReport() {
try {
Report report = new Report();
report .setExecState(ExecState.WAIT);
report .setExportContent(oracle.sql.CLOB.getEmptyCLOB());
report = entityManager.merge(report);
return report .getId();
} catch (Exception e) {
//Do nothing
}
I have following mapping in the entity Report
@Lob
@Column(name = "TB_EXPORT_CONTENT", columnDefinition="CLOB NOT NULL")
private java.sql.Clob exportContent;
But when I persist that in the database, it is not an empty clob but a
null. I have tried doing many things but same result. Can someone help me
please.

No comments:

Post a Comment