且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

错误保存并从数据库SQL oracle中获取blob

更新时间:2022-12-17 22:56:59

设置hibernate属性

 < property name =hibernate.temp.use_jdbc_metadata_defaultsvalue =false/> 

为我解决了这个问题。



将SessionFactory的lobCreator设置为NonContextualLobCreator可能是更好的解决方案(尚未尝试过)。



然而,我不确定是什么原因导致了此错误。


I'm trying to save a CLOB into the database and recovering it, but I'm getting an SQLException:

Caused by: java.sql.SQLException: Lob read/write functions called while another read/write is in progress: getBytes()
 at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2427)
 at oracle.sql.BLOB.getBytes(BLOB.java:348)
 at oracle.jdbc.driver.OracleBlobInputStream.needBytes(OracleBlobInputStream.java:181)

I figured that the problem is when I tried to get the CLOB, because it's still saving. If the CLOB is small it works fine, but when the CLOB is a little bigger it fails.

Sorry about my english and thanks

EDIT:

The annotation is:

@Lob
@Column(nullable = false)
private String body;

The save method

emailRepository.save(email); 

Setting the hibernate property

<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>

sorved the problem for me.

Setting the lobCreator for SessionFactory to NonContextualLobCreator is probably a better solution (not tried yet).

However I'm not sure what causes this error.