ArangoDB v2.8 reached End of Life (EOL) and is no longer supported.

This documentation is outdated. Please see the most recent version here: Try latest

How to use an example vertex with the java driver


Note: Arango 2.2 and the corresponding javaDriver is needed.

You want to retrieve information out of a graph using an object as example vertex, and the object contains primitive datatypes such as 'int' or 'char'. E. g. you have a graph "myGraph" with vertices that are objects of the following class...

public class MyObject {

    private String name;
    private int age;

    public MyObject(String name, int age) { = name;
        this.age = age;

    *  + getter and setter


… and edges of:

public class MyEdge {

    private String desc;

    public MyEdge(String desc) {
        this.desc = desc;

    *  + getter and setter


To retrieve all edges from vertices with a given name (e. g. “Bob”) and arbitrary age the method

arangoDriver.graphGetEdgesByExampleObject("myGraph", MyEdge.class, myVertexExample)

can not be used, because primitive datatypes (like ‘int’) can not be set to null (all attributes that are not null will be used as filter criteria).


There is a solution, but it’s not that satisfying, because you need to know the attribute names of the stored documents representing the objects. If you know the attribute names, which are used to filter vertices it’s possible to create a map as vertex example:

Map<String, Object> exampleVertex = new HashMap<String, Object>();
exampleVertex.put("name", "Bob");
CursorEntity<MyEdge> cursor = arangoDriver.graphGetEdgesByExampleMap("myGraph", MyEdge.class, exampleVertex);

Vice versa it’s no problem to retrieve all edges of vertices that have been set to a certain age (e. g. 42):

MyObject myVertexExample = new MyObject(null, 42);
CursorEntity<MyEdge> cursor = arangoDriver.graphGetEdgesByExampleObject("myGraph", MyEdge.class, myVertexExample)

Other resources

More documentation about the ArangoDB java driver is available:

Author: gschwab

Tags: #java #graph #driver