我试图将gov.nist.javax.sip.stack.SIPDialog对象序列化和反序列化为Cassandra。但是当我将它与我序列化的原始SIPDialog对象进行比较时,反序列化对象的等于比较失败了。所以看起来我在序列化中遗漏了一些东西。我正在使用ByteArraySerializer将字节读/写到Cassandra。
//保存对话框
MutationBatch mutationBatch = createMutator();
byte[] dialogBytes = SIPDialogEntity.serializeDialog(dialog);
mutationBatch.withRow(SIPDIALOGS, dialogId)
.putColumn("dialog".getBytes(),dialogBytes,null);
mutationBatch.execute();
public static byte[] serializeDialog(SIPDialog dialog) throws IOException {
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bStream);
oos.writeObject(dialog);
oos.close();
byte[] bytes = bStream.toByteArray();
bStream.close();
return bytes;
}
//阅读对话
Column<byte[]> result;
result = getKeySpace().prepareQuery(SIPDIALOGS).getKey(dialogId).getColumn("dialog").execute().getResult();
sipDialog = SIPDialogEntity.deserializeDialog(result.getByteArrayValue());
public static SIPDialog deserializeDialog(byte[] byteArrayDialog) throws IOException, ClassNotFoundException {
System.out.println("DEBUG Reading Dialog Bytes:" + byteArrayDialog );
ByteArrayInputStream bStream = new ByteArrayInputStream(byteArrayDialog);
ObjectInputStream ois = new ObjectInputStream(bStream);
SIPDialog dialog = (SIPDialog) ois.readObject();
ois.close();
bStream.close();
return dialog;
}
答案 0 :(得分:2)
SIPDialog类不会覆盖equals方法,这就是它无法进行比较的原因。请在http://java.net/jira/browse/JSIP
的啜饮中打开一个问题答案 1 :(得分:0)
如果它不是你的类,我想我会让他们添加一种方法来添加第三方bean以转换为实体,就像Guice在绑定文件中那样,这样它就可以绑定到一个可以保存的实体通过PlayOrm。如果您通过请求在PlayOrm上打开一张票,我们可能会在短短一周内获得该功能。