liveBook · Manning

REST Data extension

As explained in Quarkus in Action

REST Data is a Quarkus capability that generates customizable REST CRUD resources for Panache entities.

REST Data automates the repeated work of exposing CRUD operations for database entities. In Quarkus, it generates customizable JAX-RS resources for Panache entities, making it practical to add a CRUD API to an existing service. section 7.4 section 7.9

Choose the extension according to the persistence approach:

  • quarkus-hibernate-orm-rest-data-panache targets JDBC with Hibernate ORM and is the stable option identified here. section 7.4
  • quarkus-mongodb-rest-data-panache targets MongoDB and is identified as experimental. section 7.4
  • quarkus-hibernate-reactive-rest-data-panache targets reactive database drivers with Hibernate Reactive and is identified as experimental. section 7.4

For a relational database, add the REST Data extension together with a JDBC driver and REST JSON serialization support. Define an interface extending PanacheEntityResource with the entity type and identifier type; Quarkus then generates the resource. Customize its root path with ResourceProperties when the default path does not fit the application. section 7.4 section 7.4

Reservation CRUD resource

A Reservation service can declare `ReservationCrudResource extends PanacheEntityResource<Reservation, Long>`. Applying `@ResourceProperties(path = "/admin/reservation")` changes the generated resource root path. section 7.4

Listing 7.21 Adding REST Data extensions to the Reservation service
$ quarkus ext add quarkus-hibernate-orm-rest-data-panache \
  quarkus-jdbc-postgresql quarkus-rest-jackson
Looking for the newly published extensions in registry.quarkus.io
[SUCCESS] ✅  Extension io.quarkus:quarkus-hibernate-orm-rest-data-panache
 has been installed
 figure  Extension io.quarkus:quarkus-jdbc-postgresql was already installed
 figure  Extension io.quarkus:quarkus-rest-jackson was already installed

Use the extension command to add Hibernate ORM REST Data, the PostgreSQL JDBC driver, and REST Jackson support to the service. section 7.4

How Quarkus in Action covers it

How deep it goes
Explains extension selection, dependencies, resource declaration, and path customization, but not generated implementation internals.
Examples
Uses a ReservationCrudResource interface, extension-installation command, customized root path, and generated Swagger UI resource.
What it assumes
Assumes a Panache entity and database access, while requiring the matching driver and REST JSON serialization extension.
What you can do after
Build CRUD JAX-RS resources by adding extensions and extending PanacheEntityResource.
How it connects
Connects Panache entities with JAX-RS, Hibernate ORM, JDBC, Hibernate Reactive, MongoDB, and JSON serialization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.