我正在使用带有 Blueprint API 的 Scala 和 OrientDB。
libraryDependencies += "com.orientechnologies" % "orientdb-core" % "2.1.16"
libraryDependencies += "com.tinkerpop.blueprints" % "blueprints-core" % "2.6.0"
libraryDependencies += "com.orientechnologies" % "orientdb-graphdb" % "2.1.16"
libraryDependencies += "com.orientechnologies" % "orientdb-client" % "2.1.16"
libraryDependencies += "com.orientechnologies" % "orientdb-enterprise" % "2.1.16"
当我要存储 Option[Int] 类型的 val(到整数类型)时的行为是这样的:
val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",None) //It store an empty value
这种行为是正确的,但是如果我要存储 Option[String] (到 String 类型),我会得到:
val a: Option[String] = None
val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",a) //It store "None" instead of empty, why?
如何避免这种情况?
解决了
我已将此添加到配置中
new OrientGraphFactory().setStandardElementConstraints(false)
我改变了这样的代码:
val a: Option[String] = None //or Some("foo")
val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",a.orNull)