Can anyone advise me on how to return Generated Keys whilst also inserting a BLOB ?
My code to insert the BLOB isa as follows:
For everything else other thab BLOB's I've used code as follows:Code:getJdbcTemplate().execute ( "insert into documentimage(document_id,indexedby,"+ "indexedat,indexedwhen,filecreated,filemodified,filesize,filetype,"+ "versioncomment,binaryimage) values(?,?,?,?,?,?,?,?,?,?)", new AbstractLobCreatingPreparedStatementCallback(lobHandler) { protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException { ps.setLong(1,docImageDTO.getDocumentId().longValue()); ps.setString(2,docImageDTO.getIndexedBy()); ps.setString(3,docImageDTO.getIndexedAt()); ps.setTimestamp(4,docImageDTO.getIndexedWhen()); ps.setTimestamp(5,docImageDTO.getFileCreated()); ps.setTimestamp(6,docImageDTO.getFileModified()); ps.setBigDecimal(7,docImageDTO.getFileSize()); ps.setString(8,docImageDTO.getFileType()); ps.setString(9,docImageDTO.getVersionComment()); lobCreator.setBlobAsBinaryStream(ps, 10, is,10000 ); } }
and then retrieved the key using a KeyHolderCode:public class DocumentCreate extends SqlUpdate { public DocumentCreate(DataSource ds) { setDataSource(ds); setReturnGeneratedKeys(true); setGeneratedKeysColumnNames(new String[]{"ID"});
But I am unsure how to combine the two.


Reply With Quote