gjrwebber / spring-data-gremlin

Spring data gremlin makes it easier to implement Graph based repositories. This module extends Spring Data to allow support for potentially any Graph database that implements the Tinkerpop Blueprints 2.x API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update LinkVia documentation - specifying direction seems required

clepelli opened this issue · comments

Hello Graham,

First of all, thanks for your work.

I have generated an OrientDB shema thanks to the default shema generator.
In case of "linkvia" relationships, I have found that I must not rely only on the ToVertex / FromVertex annotations in the Edge class, but I must also specify the direction IN/OUT in the LinkVia annotation (wich defaults to OUT).

If I do not, the relatedProperty may be constructed with the wrong adjacentProperty.

see

if (relatedSchema.isEdgeSchema()) {
for (Object propertyOfRelatedSchema : relatedSchema.getProperties()) {
if (propertyOfRelatedSchema instanceof GremlinAdjacentProperty) {
// If the property has the same direction of the given property here it
// means it is the opposite property of the @EntityRelationship
if (((GremlinAdjacentProperty) propertyOfRelatedSchema).getDirection() == direction.opposite()) {
adjacentProperty = (GremlinAdjacentProperty) propertyOfRelatedSchema;
break;
}
}
}
}
}

And then there is trouble here :

Object relatedVertex = createVertexClass(relatedProperty.getAdjacentProperty().getRelatedSchema());

What happens then is the edge in the database may link from one of the linked vertices to itself instead of the other.

I would advise to remove the default OUT value and / or update the readme.

Best regards,
Clément.