Skip to content

LINKMAP + mandatory LINK field fails in recursive save within a transaction #10559

@riverlover

Description

@riverlover

Description

In OrientDB 3.x(Mine is 3.2.43) , when recursively constructing an ODocument tree within a transaction, the following scenario can trigger a validation error:

  • Child documents contain a mandatory LINK field (e.g., model)
  • Child documents are not yet saved (temporary RIDs are assigned)
  • The parent document stores child documents in a LINKMAP

Even if the model field is set in memory for each child, committing the transaction fails.

Error message:

The field 'DataValue.model' is mandatory, but not found on record: StringValue#69:-2
com.orientechnologies.orient.core.exception.OValidationException: 
The field 'DataValue.model' is mandatory, but not found on record: StringValue#69:-2

Steps to Reproduce (Scala example)

def objectValueToODocument(value: ObjectValue, modelDoc: OIdentifiable): ODocument = {
  val objectDoc = new ODocument("ObjectValue")
  objectDoc.field("model", modelDoc, OType.LINK)
  objectDoc.field("id", value.id)
  val children = value.children.map { case (k, v) => (k, dataValueToODocument(v, modelDoc)) }
  objectDoc.field("children", children.asJava, OType.LINKMAP)
  objectDoc
}

def dataValueToODocument(value: DataValue, modelDoc: OIdentifiable): ODocument = value match {
  case v: StringValue =>
    val doc = new ODocument("StringValue")
    doc.field("model", modelDoc, OType.LINK)
    doc.field("id", v.id)
    doc.field("value", v.value)
    doc
  case v: ObjectValue => objectValueToODocument(v, modelDoc)
  // Other types omitted for brevity
}

// Saving in a single transaction
db.begin()
val rootDoc = objectValueToODocument(rootObjectValue, modelDoc)
rootDoc.save()
db.commit()

Actual Result

Transaction commit fails with the error shown above, indicating that DataValue.model is missing on a temporary child document RID.

Expected Result

  • OrientDB should correctly recognize mandatory LINK fields in temporary child documents within a transaction
  • OR documentation should explicitly state that LINKMAP with mandatory LINK fields in a recursive save is not supported in a single transaction

Notes

  • Temporary RIDs (#69:-2) are generated by OrientDB for unsaved child documents
  • Saving child documents individually before saving the parent avoids the error, but breaks transactional rollback atomicity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions