5

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); 
4
  • 1
    And why does it have anything to do with Spring or Hibernate? Apr 29, 2014 at 19:27
  • please post the code where this exception is thrown?
    – Zahid M
    Apr 29, 2014 at 21:19
  • Also, please show us your entity with annotations/xml
    – Matt Byrne
    Apr 29, 2014 at 22:15
  • The annotation is @Lob @Column(nullable = false) private String body;
    – Leandro
    May 5, 2014 at 14:59

2 Answers 2

2

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.

2

I encountered a similar problem in one of the projects, setting

updatable = false

fixed the issue for me.

Example:

@Lob
@Column(name = "CONTENT", updatable = false)
Blob content;

Hibernate somehow tries to re-save the content, even when it was not changed.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.