我正在使用Scala和OrientDB与Blueprint API。
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)