{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/guides/embed/java/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "metadata",
  "url": "https://relatedb.ai/docs/guides/embed/java/samples/metadata.json",
  "page": {
    "id": "guides/embed/java",
    "title": "Use the Java client",
    "url": "https://relatedb.ai/docs/guides/embed/java/",
    "md_url": "https://relatedb.ai/docs/guides/embed/java.md"
  },
  "section": {
    "anchor": "read-result-metadata",
    "heading": "Read result metadata",
    "url": "https://relatedb.ai/docs/guides/embed/java/#read-result-metadata"
  },
  "language": "java",
  "client": "Java",
  "file": "Main.java",
  "env": null,
  "code": "import com.relate.Database;\nimport com.relate.Notification;\n\npublic class Metadata {\n    static final String TEAM = \"\"\"\n        CREATE (ada:Person {name: 'Ada', role: 'engineer'}),\n               (grace:Person {name: 'Grace', role: 'engineer'}),\n               (noor:Person {name: 'Noor', role: 'maintainer'}),\n               (relate:Project {name: 'relate', language: 'Rust'}),\n               (tck:Project {name: 'opencypher-tck', language: 'Gherkin'}),\n               (ada)-[:WORKS_ON {since: 2024}]->(relate),\n               (grace)-[:WORKS_ON {since: 2023}]->(relate),\n               (grace)-[:WORKS_ON {since: 2022}]->(tck),\n               (noor)-[:MAINTAINS]->(relate),\n               (ada)-[:KNOWS]->(grace)\n        \"\"\";\n\n    static void show(String label, Database.Result r) {\n        System.out.println(label + \": type=\" + r.getQueryType() + \" namespace=\" + r.getNamespace()\n            + \" bookmark=\" + r.getBookmark() + \" columns=\" + r.columns());\n    }\n\n    public static void main(String[] args) {\n        try (Database db = Database.open(\":memory:\");\n             Database.Connection conn = db.connect()) {\n            show(\"create\", conn.query(TEAM));\n            show(\"read\", conn.query(\"MATCH (p:Person) RETURN p.name AS name\"));\n            show(\"update\", conn.query(\"MATCH (p:Person {name: 'Ada'}) SET p.role = 'lead' RETURN p.role AS role\"));\n            show(\"index\", conn.query(\"CREATE INDEX person_name FOR (p:Person) ON (p.name)\"));\n            show(\"routed\", conn.query(\"USE system SHOW DATABASES YIELD name RETURN name\"));\n\n            var explained = conn.query(\"EXPLAIN MATCH (a:Person), (b:Project) RETURN a.name, b.name\");\n            System.out.println(\"plan root: \" + explained.getPlan().root.operator);\n            for (Notification n : explained.getNotifications()) {\n                System.out.println(n.getGqlStatus() + \" \" + n.getSeverity() + \" \" + n.getTitle());\n                System.out.println(\"remedy: \" + n.getRemedy());\n            }\n        }\n    }\n}",
  "code_sha256": "ecb967bf50e8b38a40675987b2bcdf49962863a14d24e8a850c671c66e29b02f",
  "source_sha256": "4fb5ce66a638f0ff6cc7fdcce59b2ec90597af5e39a9aa4f4a466192af1e7189",
  "output": {
    "text": "create: type=WRITE namespace=NEO4J bookmark=relate:1 columns=[]\nread: type=READ namespace=NEO4J bookmark=null columns=[name]\nupdate: type=READ_WRITE namespace=NEO4J bookmark=relate:2 columns=[role]\nindex: type=SCHEMA namespace=NEO4J bookmark=relate:3 columns=[]\nrouted: type=READ namespace=SYSTEM bookmark=null columns=[name]\nplan root: ProduceResults\n03N90 INFORMATION Cartesian product\nremedy: Give the patterns a join anchor: reuse a node variable across them, or add a pattern that relates their endpoints; otherwise run them as separate queries.",
    "sha256": "e6c4dce05d4740d1711b2cfe82345cab13357bb6794c12d8332787cd65b654d2"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "Java",
      "package": "com.relate:relate",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "A copy of clients/java at upstream v0.1.2 (f0c09d2) packaged with Maven 3.10.0 (relate-0.1.2.jar, with JNA 5.14.0 and Jackson databind 2.17.2 on the classpath), loading librelate_ffi built from the same commit.",
      "toolchain": {
        "jdk": "Temurin 21.0.13+9"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_JAVA",
      "RELATE_JAVA_CLASSPATH",
      "RELATE_LIB"
    ],
    "program": "<build dir>/Main.java",
    "files": [],
    "build": null,
    "run": {
      "command": [
        "$RELATE_JAVA",
        "-Djna.tmpdir=<build dir>",
        "-Drelate.native.cache=<build dir>/native",
        "-cp",
        "$RELATE_JAVA_CLASSPATH",
        "<build dir>/Main.java"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "RELATE_LIB": "$RELATE_LIB"
      },
      "unset": [
        "JAVA_TOOL_OPTIONS",
        "JDK_JAVA_OPTIONS"
      ],
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
