I have a table with few fields out of which 2 are of Varchar and Blob type. When I'm retrieving them using queryForMap, I'm getting a map instance with two keys(name of the column). I'm able to cast varchar to String simply but getting ClassCast Exception doing the same with Object.
file = new File(System.currentTimeMillis() + (String) map.get("SAMPLE_DOC_FILE_NAME"));
blob = (Blob) map.get("SAMPLE_DOC");
My DAO layer method is:
public Map<String, Object> getSampleDoc1(String docName) throws SQLException {
String query = "select form.sample_doc_file_name as SAMPLE_DOC_FILE_NAME, form.sample_document as SAMPLE_DOC from forms form where form.document_name=?";
return localJdbcTemplateObject.queryForMap(query, docName);
}
Exception - java.lang.ClassCastException: [B cannot be cast to java.sql.Blob
What can I do to get back this object as Blob?