/** * Create a new CLOB value with the given character stream. * @param reader the character stream containing the CLOB value * @param length the length of the CLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(Reader reader, int length, LobHandler lobHandler) { this.content = reader; this.length = length; this.lobCreator = lobHandler.getLobCreator(); }
@Test public void testGetBlobAsBytes() throws SQLException { lobHandler.getBlobAsBytes(rs, 1); verify(rs).getBytes(1); }
@Test public void testGetClobAsString() throws SQLException { lobHandler.getClobAsString(rs, 1); verify(rs).getString(1); }
@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; } }
/** * Create a new BLOB/CLOB value with the given stream. * @param stream the stream containing the LOB value * @param length the length of the LOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(InputStream stream, int length, LobHandler lobHandler) { this.content = stream; this.length = length; this.lobCreator = lobHandler.getLobCreator(); }
private Object getBlobAsObject(ResultSet rs, String columnName) throws SQLException { byte[] bytes = this.lobHandler.getBlobAsBytes(rs, columnName); return this.conversionService.convert(bytes, TypeDescriptor.valueOf(byte[].class), TypeDescriptor.valueOf(Object.class)); }
@Override protected Object nullSafeGetInternal( ResultSet rs, String[] names, Object owner, LobHandler lobHandler) throws SQLException { return lobHandler.getClobAsString(rs, names[0]); }
@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; } }
/** * Create a new BLOB value with the given byte array. * @param bytes the byte array containing the BLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(@Nullable byte[] bytes, LobHandler lobHandler) { this.content = bytes; this.length = (bytes != null ? bytes.length : 0); this.lobCreator = lobHandler.getLobCreator(); }
@Override public Message<?> mapRow(ResultSet rs, int rowNum) throws SQLException { byte[] blobAsBytes = this.lobHandler.getBlobAsBytes(rs, "MESSAGE_BYTES"); if (blobAsBytes == null) { return null; } else { return (Message<?>) this.deserializer.convert(blobAsBytes); } }
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler) throws SQLException { return lobHandler.getClobAsString(rs, index); }
/** * Create a new CLOB value with the given content string. * @param content the String containing the CLOB value * @param lobHandler the LobHandler to be used */ public SqlLobValue(@Nullable String content, LobHandler lobHandler) { this.content = content; this.length = (content != null ? content.length() : 0); this.lobCreator = lobHandler.getLobCreator(); }
@Override public Message<?> mapRow(ResultSet rs, int rowNum) throws SQLException { byte[] messageBytes = JdbcMessageStore.this.lobHandler.getBlobAsBytes(rs, "MESSAGE_BYTES"); if (messageBytes == null) { return null; } else { return (Message<?>) JdbcMessageStore.this.deserializer.convert(messageBytes); } }
public String getClobAsString(ResultSet rs, int columnIndex) throws SQLException { return lobHandler.getClobAsString(rs, columnIndex); }
@Override public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException { LobCreator lobCreator = this.lobHandler.getLobCreator(); try { setValues(ps, lobCreator); return ps.executeUpdate(); } finally { lobCreator.close(); } }
@Override protected Object nullSafeGetInternal( ResultSet rs, String[] names, Object owner, LobHandler lobHandler) throws SQLException { return lobHandler.getBlobAsBytes(rs, names[0]); }
@Override public void setValues(PreparedStatement ps) throws SQLException { ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); } });
protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler) throws SQLException { return lobHandler.getBlobAsBytes(rs, index); }
@Override public void setValues(PreparedStatement ps, int i) throws SQLException { Long executionId = executionIdIterator.next(); String serializedContext = serializedContexts.get(executionId); String shortContext; String longContext; if (serializedContext.length() > shortContextLength) { // Overestimate length of ellipsis to be on the safe side with // 2-byte chars shortContext = serializedContext.substring(0, shortContextLength - 8) + " ..."; longContext = serializedContext; } else { shortContext = serializedContext; longContext = null; } ps.setString(1, shortContext); if (longContext != null) { lobHandler.getLobCreator().setClobAsString(ps, 2, longContext); } else { ps.setNull(2, getClobTypeToUse()); } ps.setLong(3, executionId); }