Storing stream with JPA into BLOB fails?

View: New views
2 Messages — Rating Filter:   Alert me  

Storing stream with JPA into BLOB fails?

by Ari Heino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to save InputStream into blob column, but I get error while getting stream from blob object with JPA.

It seems that reading/writing to empty blob instance causes failure, so is it at all possible to insert stream with JPA/EclipseLink? Or only via JDBC like:

pstmt.setBinaryStream(1,new ByteArrayInputStream(dataAsByteArray),dataAsByteAr ray.length);

I tried using "BLOB.getEmptyBLOB()" with Oracle 10, but that just returns some 17000-series errror code about not being able to deal with empty blob.

I'm using EclipseLink 1.1.0. in OSGi/Equinox container.

Re: Storing stream with JPA into BLOB fails?

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can use stream binding in EclipseLink using DatabaseLogin.useStreamsForBinding(), (using a SessionCustomizer).

For Oracle Lobs you may need to use the Oracle9Platform (or 8/9/10) with the thin driver for lobs over 4k.


Ari Heino wrote:
I'm trying to save InputStream into blob column, but I get error while getting stream from blob object with JPA.

It seems that reading/writing to empty blob instance causes failure, so is it at all possible to insert stream with JPA/EclipseLink? Or only via JDBC like:

pstmt.setBinaryStream(1,new ByteArrayInputStream(dataAsByteArray),dataAsByteAr ray.length);

I tried using "BLOB.getEmptyBLOB()" with Oracle 10, but that just returns some 17000-series errror code about not being able to deal with empty blob.

I'm using EclipseLink 1.1.0. in OSGi/Equinox container.