尝试访问关系文档时出现以下异常:
java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to com.orientechnologies.orient.core.record.impl.ODocument
通过:
Collection<ODocument> field = myDoc.field("MY_FIELD_NAME");
if(field != null) {
return field;
} else {
return Collections.emptySet();
}
奇怪的是,这种情况并非总是发生,大部分时间都是预期的。
答案 0 :(得分:0)
根据字段的内容,您可以使用界面OIdentifiable
代替ODocument
。
尝试使用:
Collection<OIdentifiable> field = myDoc.field("MY_FIELD_NAME");
if(field != null) {
return field;
} else {
return Collections.emptySet();
}