Chapter 7. Persistence
The underlying persistence strategies used by Quarkus should already be familiar to you. Transactions, datasources, Java Persistence API (JPA), and so on are all standards that have existed for many years. Quarkus uses these and, in some cases, builds on top of them to make working with persistent stores easier. In this chapter, you will learn about working with persistent stores in Quarkus. We cover both traditional relational database management systems (RDBMS) and NoSQL databases.
Quarkus has some additional gems if you’re using a traditional RDBMS or MongoDB in the form a Panache, an opinionated, entity or active record type API. Panache simplifies much of the standard JPA syntax, making your application easier to read and maintain—again, helping you to be more productive!
In this chapter, you’ll learn how to accomplish the following tasks:
-
Configure datasources
-
Deal with transactions
-
Manage database schema migrations
-
Make use of the Panache API
-
Interact with NoSQL data stores
7.1 Defining a Datasource
Problem
You want to define and use a datasource.
Solution
Use the Agroal extension and application.properties.
Discussion
Agroal is the preferred datasource and connection pooling implementation in Quarkus. The Agroal extension has integrations with security, transaction management, and health metrics. While it does have its own extension, if you are using Hibernate ORM or Panache, the Agroal extension is pulled in transitively. You will ...
Get Quarkus Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.