Hi Rob,
If your return type is not a document you have 4 options:
1. use String as return type, which give you a raw json
ArangoCursor<String> cursor = arangoDB.db().query("your query", null, null, String.class);
2. use VPackSlice as return type, get the documents from it and deserialize them with the class VPack to BaseDocument
VPack deserialiser = new VPack.Builder().build();
ArangoCursor<VPackSlice> cursor = arangoDB.db().query("your query", null, null, VPackSlice.class);
for (; cursor.hasNext();) {
VPackSlice vpack = cursor.next();
BaseDocument doc1 = deserialiser.deserialize(vpack.get("document1"), BaseDocument.class);
BaseDocument doc2 = deserialiser.deserialize(vpack.get("document2"), BaseDocument.class);
}
3. use Map as return type
ArangoCursor<Map> cursor = arangoDB.db().query("your query", null, null, Map.class);
for (; cursor.hasNext();) {
Map<String, Object> result = cursor.next();
Map<String, Object> document1 = (Map<String, Object>) result.get("document1");
Map<String, Object> document2 = (Map<String, Object>) result.get("document2");
}
4. make your own POJO which reflect your qery result and use it as return type
public class MyResult {
private BaseDocument document1;
private BaseDocument document2;
public MyResult() {
super();
}
// setter + getter
}
ArangoCursor<MyResult> cursor = arangoDB.db().query("your query", null, null, MyResult.class);
for (; cursor.hasNext();) {
MyResult result = cursor.next();
BaseDocument document1 = result.getDocument1();
BaseDocument document2 = result.getDocument2();
}
If you have nested objects and want to use BaseDocument, you can access them with getAttribute(key) and cast the Object result to Map<String, Object> like in option 3.
BaseDocument baseDocument = ...
Map<String, Object> nestedObj = (Map<String, Object>) baseDocument.getAttribute("nestedObjKey");
Generally you do not have to use BaseDocument. It is just a little helper for small things, where you do not have a POJO for. The driver automatically de-/serialize your POJOs when insert/get/update/replace or query.
Mark