7 Database access
This chapter covers
- Learning how to connect Quarkus application to the database
- Introducing Hibernate object-relational mapping with Panache
- Explaining Quarkus approaches to the database access
- Integrating reactive database access to Quarkus applications
Databases. We 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 whenever 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 database access for your applications.
This chapter introduces Panache, an API that Quarkus adds on top of the well-known Hibernate ORM framework. Panache implements the active record pattern and provides even further simplification over the ORM provided by Hibernate. However, we don’t stop there. As we explain, Panache is also usable with the repository pattern (a repository is a design pattern implemented as a Java object that represents the database table and has methods for interacting with it).