@Test public void testGetBlobAsBinaryStream() throws SQLException { lobHandler.getBlobAsBinaryStream(rs, 1); verify(rs).getBinaryStream(1); }
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler) throws SQLException, IOException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, index); if (is != null) { ObjectInputStream ois = new ObjectInputStream(is); try { return ois.readObject(); } catch (ClassNotFoundException ex) { throw new SQLException("Could not deserialize BLOB contents: " + ex.getMessage()); } finally { ois.close(); } } else { return null; } }
@Override protected Object nullSafeGetInternal( ResultSet rs, String[] names, Object owner, LobHandler lobHandler) throws SQLException, IOException, HibernateException { InputStream is = lobHandler.getBlobAsBinaryStream(rs, names[0]); if (is != null) { ObjectInputStream ois = new ObjectInputStream(is); try { return ois.readObject(); } catch (ClassNotFoundException ex) { throw new HibernateException("Could not deserialize BLOB contents", ex); } finally { ois.close(); } } else { return null; } }