chapter seven

7 Database access

 

This chapter covers

  • Learning how to connect Quarkus application to the database
  • Introducing Hibernate ORM with Panache
  • Explaining Quarkus approaches to the database access
  • Integrating reactive database access to Quarkus applications

Databases. I believe all of us can agree that we must do something with the database at least a few times in our careers. From simple column adjustments to sophisticated migrations, these might become challenging problems to solve. This is why there are a lot of libraries helping us with database access, object-relational mapping (ORM), and migrations every time we need them.

In the previous chapter, we delegated the user management and credentials storing to the Keycloak server that manages its own persistent store. While this is suitable for user handling, it surely isn’t ideal for our custom business data that the Car rental system manages. In this chapter, we concentrate on learning how Quarkus manages databases from your applications.

7.1 Panache

7.1.1 Active record pattern

7.1.2 Getting started with Panache

7.1.3 Using Panache in the Reservation service

7.2 Panache repository pattern

7.2.1 Utilizing repository pattern with MariaDB

7.2.2 Using the repository pattern in Inventory

7.3 Traditional ORM/JPA data access

7.4 REST Data

7.5 Transactions

7.5.1 Declarative transactions

7.5.2 Manual handling with QuarkusTransaction

7.5.3 Transactions with Panache

7.6 Panache with NoSQL

7.6.1 Utilizing MongoDB with Panache

7.6.2 Using the Panache MongoDB in Rental

7.6.3 Adjusting Reservation service to the Rental service updates

7.7 Reactive data access

7.8 Wrap up and next steps