As stated, this doesn't work. It fails inside the db.command() when it tries to cast an OrientEdge to an ODocument.
I don't think it is due to the ObjectAPI, in fact this indicates a bigger problem.
Since the Graph API is built on top of the ODocument API this should, imo, be possible:
String qe = "CREATE EDGE " + EdgeName.class.getSimpleName() + " FROM " + from.getId() + " TO " + to.getId();
List<ODocument> oDocEdges = db.getUnderlying().command(new OCommandSQL(qe)).execute();
oDocEdges.iterator().next().getClass();
But it now get a class cast exception on the last line. That is, even if explicitly use the document API it still returns an OrientEdge.
That surely can not be the expected behavior since we can return an edge just fine?
In fact, I think if that problem is fixed we won't have any issues with the original question either.
Or am I completely wrong here?