Hands-On Cloud-Native Applications with Java and Quarkus by Francesco Marchioni

Hands-On Cloud-Native Applications with Java and Quarkus by Francesco Marchioni

Author:Francesco Marchioni [Francesco Marchioni]
Language: eng
Format: epub
Tags: COM060180 - COMPUTERS / Web / Web Services and APIs, COM051280 - COMPUTERS / Programming Languages / Java, COM048000 - COMPUTERS / Systems Architecture / Distributed Systems and Computing
Publisher: Packt Publishing
Published: 2019-12-13T09:01:51+00:00


Hibernate ORM is the standard way to map database structures into Java objects. The main downside of using an ORM tool is that even a simple database structure requires lots of boilerplate code (such as getter and setters methods). Also, you have to include basic query methods in your repository classes, which makes the work quite repetitive. In this section, we will learn how to use Hibernate Panache to simplify and accelerate the development of our applications.

To get started with Hibernate ORM with Panache, let's check the second example for this chapter, which is located in the Chapter05/hibernate-panache folder in this book's GitHub repository. We recommend importing the project into your IDE before you move on.

If you take a look at the project's configuration, you will see that we have included quarkus-hibernate-orm-panache in the pom.xml file:

<dependency>

<groupId>io.quarkus</groupId>

<artifactId>quarkus-hibernate-orm-panache</artifactId>

</dependency>

This is the only configuration that we need to use Hibernate Panache. Now comes the funny part. There are two strategies for plugging Panache into your entity:

Extending the io.quarkus.hibernate.orm.panache.PanacheEntity class: This is the simplest option as you will get an ID field that is auto-generated.

Extending io.quarkus.hibernate.orm.panache.PanacheEntityBase: This option can be used if you require a custom ID strategy.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.