try {
OCApp app = ((OCEConnection) getStatement().getConnection()).getApplication();
OCXDTOSerializer serializer = app.getXDTOSerializer();
OCXMLWriter writer = app.newXMLWriter();
writer.setString("UTF-8");
_OCCommonObject commonObject = (_OCCommonObject) ref.getObject();
serializer.writeXML(writer, commonObject);
String r1 = writer.close();
bytes = r1.getBytes();
} catch (JIException e) {
throw new SQLException(e);
}