OrientDB无法持久化顶点,返回ORID但是返回空顶点,例如v(null)[#3:4]

时间:2016-05-22 14:55:53

标签: orientdb

我无法让OrientDB使用java API来持久化OrientVertex或oDocument。 虽然它在我使用SQL和OCommand时起作用。

尝试使用foll代码

来保留顶点
  val factory: OrientGraphFactory = new OrientGraphFactory("plocal:localhost/database", "admin", "admin");
  val graph = factory.getTx
  val oDocument: ODocument = UserEntityMapper.toODocument(user)
  println("ODocument =  = "+ oDocument)
  val orientVertex = new OrientVertex(graph, oDocument)
  println("BEFORE orientVertex  = "+ orientVertex)
  graph.commit()
  println("AFTER orientVertex  = "+ orientVertex)

我将调试打印输出为

ODocument = {phoneNumber:45435345,email:moses @ email.com,dateOfBirth:-766198800000,lastName:Johnson,firstName:Moses,avatarURL:null,loginInfo:{providerID:credentials,providerKey:moses@email.com} ,用户ID:a8d96be9-1d09-4e8f-bf8d-6a0d32e1e5aa}

在orientVertex = v(null)[#3:-2]

之前

在orientVertex = v(null)之后[#3:4]

如您所见,顶点为空。什么都没有坚持下去。我得到一个改变集群位置编号的ORID。

当我重复保存时,群集位置编号会递增

在orientVertex = v(null)之前[#3:-3]

在orientVertex = v(null)之后[#3:7]

为什么会发生这种情况,我该如何解决这个问题呢?没有例外,所以我不知道什么是错的。用户的群集/表存在于所有右侧字段的数据库中。

我使用的是orientdb-community-2.2.0和Scala。

问候

1 个答案:

答案 0 :(得分:0)

最后整理出来。我在没有类名的情况下实例化了ODocument。在

UserEntityMapper.toODocument(user)

我做的相当于这个

new ODocument(Map("name"->"john", "city" -> "London"))

而不是

new ODocument("User").fromMap(Map("name"->"john", "city" -> "London"))

所以DB没有拿起User类。

感谢actual指出我正确的方向