Javajson

CRUD with JSON Relational Duality Views

JDBC CRUD sample for JSON Relational Duality Views with OSON and Testcontainers.

JSONDuality ViewsTestcontainers#Duality Views#Java#JSON#Testcontainers
What this sample helps you learn

[Click here for the in-depth blog](https://andersswanson.dev/2026/02/24/hands-on-crud-with-jdbc-and-json-relational-duality-views/)

What this sample demonstrates

JSON

Document-shaped data and SQL/JSON querying inside Oracle AI Database.

Use when records need flexible structure without leaving SQL, indexes, constraints, and transactions.

Duality Views

Document-shaped access over relational tables using JSON Relational Duality Views.

Use when APIs need JSON documents without giving up relational storage, SQL, constraints, and transactions.

Testcontainers

Disposable Oracle AI Database Free containers for repeatable local and integration tests.

Use when tests need real database behavior without sharing a long-lived development instance.

Highlights

  • Serialize Java records into Oracle OSON using a reusable OSONMapper.
  • Insert JSON payloads into a JDV and retrieve generated keys via JDBC RETURNING.
  • Read JDV rows with JsonParser, map them back to typed objects, and apply json_transform updates.
  • Delete documents through the JDV and cascade relational changes automatically.