ClassCastException而在两个顶点之间获取边缘属性值时 [英] ClassCastException while fetching edge property value bewteen two vertices

查看:63
本文介绍了ClassCastException而在两个顶点之间获取边缘属性值时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取两个顶点之间的边属性值,并获得低于异常的值

I am trying to fetch edge property value between two vertices and getting below exception

java.lang.ClassCastException:无法将java.lang.String强制转换为 scala.runtime.Nothing $

java.lang.ClassCastException: java.lang.String cannot be cast to scala.runtime.Nothing$

Env:Titan InMemory

Env: Titan InMemory

代码:

val age = Key[Int]("age")

 A ---("knows",age -> 10) --> B

克里姆林宫查询:

graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()
      .has("ID", "B").select("x").properties("age").headOption().get

输出: p [age-> 10]

graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()
          .has("ID", "B").select("x").label().head()

输出:知道

graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()
      .has("ID", "B").select("x").values("age").head()

输出:

java.lang.ClassCastException:无法将java.lang.String强制转换为 scala.runtime.Nothing $

java.lang.ClassCastException: java.lang.String cannot be cast to scala.runtime.Nothing$

当我尝试获取属性值的任何想法时,我都会收到此错误

Any idea when i try to fetch property value , i am getting this error

与gremlin控制台相同 http://gremlinbin.com/bin/view/58044fa931772

Same works with gremlin console http://gremlinbin.com/bin/view/58044fa931772

推荐答案

不确定这是正确的解决方案. 这解决了我的问题.

Not sure this is correct solution. This resolved my problem.

我正在将整数值插入edge属性

I was inserting integer value to edge property

之前:mgmt.makePropertyKey("age").dataType(classOf[String]).cardinality(Cardinality.SET).make()

之后:

mgmt.makePropertyKey("age").dataType(classOf[Integer]).cardinality(Cardinality.SET).make()

更改此设置后,发生以下错误

After changing this , below error was occuring

java.lang.ClassCastException:无法将java.lang.Integer强制转换为 scala.runtime.Nothing $

java.lang.ClassCastException: java.lang.Integer cannot be cast to scala.runtime.Nothing$

之前:

val age_value = graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()
      .has("ID", "B").select("x").values("age").head()

之后:

val age_value:Integer = graph.traversal().V().has("ID", "A").bothE("knows").as("x").otherV()
      .has("ID", "B").select("x").values("age").head()

这篇关于ClassCastException而在两个顶点之间获取边缘属性值时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆