How to handle Options in orientdb blueprint

68 Views Asked by At

I'm using Scala and OrientDB with 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"

The behavior when i'm going to store a val of type Option[Int](to an integer type) is this:

val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",None) //It store an empty value

This behavior is correct, but if i'm going to store an Option[String] (to a String type) i get this:

val a: Option[String] = None
val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",a) //It store "None" instead of empty, why?

How can avoid this?

SOLVED

I've added this to configuration

new OrientGraphFactory().setStandardElementConstraints(false)

And i changed the code like this:

val a: Option[String] = None //or Some("foo")
val vertex: Vertex = graph.addVertex("prova",null)
vertex.setProperty("foo",a.orNull)
0

There are 0 best solutions below