我在使用與tinkerpop的框架關聯的@GremlinGroovy註釋時收到以下錯誤。Gremlin Groovy帶框架的ClassCastException
java.lang.ClassCastException: com.thinkaurelius.titan.graphdb.relations.CacheEdge cannot be cast to com.tinkerpop.blueprints.Vertex
at com.tinkerpop.frames.structures.FramedVertexIterable$1.next(FramedVertexIterable.java:36)
at com.tinkerpop.frames.annotations.gremlin.GremlinGroovyAnnotationHandler.processVertex(GremlinGroovyAnnotationHandler.java:75)
at com.tinkerpop.frames.annotations.gremlin.GremlinGroovyAnnotationHandler.processElement(GremlinGroovyAnnotationHandler.java:114)
at com.tinkerpop.frames.annotations.gremlin.GremlinGroovyAnnotationHandler.processElement(GremlinGroovyAnnotationHandler.java:30)
at com.tinkerpop.frames.FramedElement.invoke(FramedElement.java:83)
at com.sun.proxy.$Proxy81.getProxyCandidateEdgeFromPersonUuid(Unknown Source)
at com.company.prod.domain.Person$Impl.toImpl(Person.java:100)
....
以下行導致錯誤:
FooEdge fe = foo.getFooEdgeFromUuid(this.getUuid());
這是調用此方法:
@GremlinGroovy("it.outE('has').filter{it.inV().has('uuid', T.eq, uuid).hasNext()}")
FooEdge getFooEdgeFromUuid(@GremlinParam("uuid") String uuid);
我也試過以下遍歷(這會導致同樣的錯誤):
@GremlinGroovy("it.out('has').has('uuid', T.eq, uuid).inE('has')")
Howeve r,當我打開一個gremlin shell來測試相同的確切遍歷時 - 一切都很順利。對可能導致問題的任何想法?
我之所以使用hasNext()是因爲過濾器閉包需要一個布爾結果來確定某個特定頂點是否通過。 – cscan
oops - 你是對的 - 我誤解了它 - 對我的回答稍作更新.... –