Neo4J OGM字段主id在Scala中为空

Neo4J OGM字段主id在Scala中为空,scala,neo4j,neo4j-ogm,Scala,Neo4j,Neo4j Ogm,这是我的节点实体类: @NodeEntity class SutStateEntity( @Id @GeneratedValue @Index(unique = true) val id: String) { def this(sutStateIdentifier: SutStateIdentifier) = this(sutStateIdentifier.hash) def this() = this("") } 我正在使用sutStateIdent

这是我的节点实体类:

@NodeEntity
class SutStateEntity(
    @Id
    @GeneratedValue
    @Index(unique = true)
    val id: String) {

  def this(sutStateIdentifier: SutStateIdentifier) = this(sutStateIdentifier.hash)
  def this() = this("")
}
我正在使用sutStateIdentifier的唯一散列值作为我的id。 当我将SutStateEntity存储在事务中时:

val sutStateEntity = new SutStateEntity(sutStateIdentifier)
session.save(sutStateEntity)
我得到以下例外情况:

Exception in thread "main" org.neo4j.ogm.exception.core.MappingException: `Field with primary id is null for entity ....SutStateEntity@34aa8b61`
我已经读到,如果我没有指定默认构造函数,就会发生这个错误

编辑: 以下示例有效:

@Id
@GeneratedValue
var id: java.lang.Long = 0L

我想,我必须将字段id更改为var,但如果我使用字符串,它仍然不起作用。即使使用java.lang.String也不行。

分配错误。这项工作:

@Id
@GeneratedValue
var id: java.lang.Long 

分配错误。这项工作:

@Id
@GeneratedValue
var id: java.lang.Long