Postgresql 8.4 reading OID style BLOBs with Hibernate

Posted by peter on Stack Overflow See other posts from Stack Overflow or by peter
Published on 2010-06-11T18:36:06Z Indexed on 2010/06/11 18:43 UTC
Read the original article Hit count: 416

Filed under:
|
|

I am getting this weird case when querying Postgres 8.4 for some records with Blobs (of type OIDs) with Hibernate. The query does return all right but when my code wants to read the content of the BLOB with the simple code below, it gets 0 bytes back

public static byte[] readBlob(Blob blob) throws Exception {
    InputStream is = null;
    try {
        is = blob.getBinaryStream();
        return org.apache.commons.io.IOUtils.toByteArray(is);
    }
    finally {
        if (is != null)
            try {
                is.close();
            }
            catch(Exception e) {}
    }
}

Funny think is that I am getting this behavior only since I've started adding more then one such records to the table. The underlying JDBC library is type 3 (postgresq 8.4-701). Can someone give me a hint as to how to solve this issue? Thanks

Peter

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate