class InsertOperation extends AbstractNeo4JOperation {

    @Override
    public void execute(final Connection connection, final Graph<Node, Edge> graph) throws SQLException {
        // create query to insert nodes and edges
        final List<Path> paths = graph.vertexSet().stream().map(n -> n.toPath().withAllAttributes().build()).collect(toList());
        graph.edgeSet().stream().map(e -> e.toPath().withAllAttributes().build()).collect(toCollection(() -> paths));

        final UpdateNext query = create(paths.toArray(new Path[paths.size()]));

        executeQuery(connection, query.toString());
    }

}