> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java ontology SDKs

> Typed records, queries, operations and retained answers in an independent Maven artifact

Java consumer SDKs require JDK 21 or newer and generate domain records, builders,
ID records, enum literals, typed queries, ordinary functions, operations, and named
question outputs. Configure a Maven artifact and Java package in a version 4 SDK
config:

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "version": 4,
  "resources": ["collection:orders", "operation:orders:approve", "function:analytics:revenue"],
  "targets": [{
    "language": "java",
    "package": {"name": "business-sdk", "groupId": "com.acme", "module": "com.acme.business", "version": "0.1.0"},
    "output": "generated/java"
  }]
}
```

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection sdk generate --config bijection.sdk.json --java-runtime-version 0.1.0 --url "$BIJECTION_URL"
bijection sdk generate --config bijection.sdk.json --frozen --check
mvn -f generated/java/pom.xml package
```

The POM pins `com.bijection:consumer-sdk` exactly. Publish the artifact through your
normal Maven repository workflow. Its JAR includes the selected contract, schemas,
resource documentation, and examples. Independent consumers require no backend
source. The runtime uses the JDK HTTP client and lossless native codecs.

```java theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
var journal = new FileRequests(Path.of("./request-journal"), deploymentURL, "billing-user");
var client = new Workspace(Options.of(deploymentURL, this::businessToken).withRequests(journal));
var query = client.collections().orders().query()
    .where(Fields.Order.AMOUNT.greaterThan(10L));
var page = query.page(new PageOptions(25, null));
for (var row : page.rows()) {
    if (row.amount().isPresent()) System.out.println(row.amount().value());
}
```

`Presence<T>` separates omission from a present nullable value. Native integers
use `Long`, bytes use `byte[]`, and numbers use `Double`. IDs and semantic scalar
values have named wrappers. Structural codecs reject unknown and missing fields.
Generated builders retain required-argument checks at the contract boundary.
The backend owns authorization, ID membership, and semantic admission.

```java theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
var args = OrdersApproveArgs.builder()
    .targetId(new OrdersID(orderID))
    .amount(9007199254740993L)
    .build();
var request = client.operations().orders().approve().capture(args, "approval-42");
try {
    var outcome = request.invoke();
} catch (OutcomeUnknown uncertain) {
    var original = client.operations().orders().approve().restore(uncertain.requestID());
    var outcome = original.recover();
}
```

The generated examples show each resource's exact method and field names.
Namespace bindings are lazy; schemas are packaged as resources rather than large
Java string constants. One object record supports at most 240 fields, keeping its
constructor below JVM limits. String enums support at most 256 members per type. Generation rejects larger records and enums explicitly.

Questions expose `ask`, `restore`, and `explain`. A retained `Request<O>` implements
`AutoCloseable`: use try-with-resources, an explicit bounded `collect(maxRows)`, and
`result(Duration)` for local wait limits. Interruption or timeout leaves the request
recoverable. A durable close intent prevents further result reads and makes
`runtime().retry(id)` replay close alone. Typed restore refuses a changed model;
neutral operation inspection retains the original captured identity.

Queries offer typed `select`, `aggregate`, `related`, `union`, `intersect`, and
`subtract`. Continuations bind the query, input digest, basis, and caller. Remote
rowsets expose query bindings without inventing point readers. `run` accepts an
explicit `ExecutionBinding`; Bijection does not provision compute.

`watch(Duration)` is a demand-aware `Flow.Publisher` using native polling.
Cancellation interrupts only its local worker. Refusals deliver an observation
with no stale value. Private file journals require POSIX permissions, atomic hard
links, and directory synchronization; supply a durable `RequestStore` adapter on
other platforms. Candidate Maven installation, hosted qualification, and public
release availability are distinct evidence levels.

Saved proposals return typed `Proposal<R>` values. Review, approve, or revoke through `runtime().reviewProposal`, `approveProposal`, and `revokeApproval`; native policy decides each caller’s authority. Submit the same capture with `request.invoke(proposal)`. The proposal locator carries no replacement input.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.