This chapter covers:
- What is Panache
- Simplifying JPA development with Panache
- Database testing with Panache and
@QuarkusTest
In chapter 2, creating the Account Service showed how to develop JAX-RS endpoints with Quarkus. This chapter will take that Account Service and add database storage for the account data, instead of the data only being held in memory.
As most microservices will need to store some type of data, or interact with data stored by another microservice, being able to read and store data to a database is a key feature to learn and understand. Though stateless microservices are "a thing", and certainly a goal, if appropriate, for a microservice, there are also times when denying the need to store data leads to unnecessary mental gymnastics. Leading to a significantly more complex distributed system.
To simplify the development of microservices requiring storage, Quarkus created Hibernate ORM with Panache (Panache). An opinionated means of storing and retrieving state from a database, heavily inspired from the Play framework, Ruby on Rails, and JPA experience. Panache offers two different paths, depending on developer preference, Active Record and Data Repository. The Data Repository approach will be familiar to those with experience in Spring Data JPA.