object 轉字節再轉BLOB
Object o = map.get(values.get(j));
byte[] bytes = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(o);
oos.flush();
bytes = bos.toByteArray ();
oos.close();
bos.close();
} catch (IOException ex) {
ex.printStackTrace();
}
Blob bpmnBlob = new SerialBlob(bytes);
字符串轉字節轉BLOB
String st = (String) map.get(values.get(j));
byte[] bpmnBytes = new byte[0];
try {
JsonNode editorNode = new ObjectMapper().readTree(st);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
BpmnModel model = jsonConverter.convertToBpmnModel(editorNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Blob bpmnBlob = new SerialBlob(bpmnBytes);