In this blog, we will cover accessing data using Micronaut JPA-Hibernate.
What is Micronaut
It is an open-source JVM-based software framework for building lightweight, modular applications and microservices. Micronaut has the ability to help developers create apps and microservices with small memory footprints and short startup times.
What are JPA and Hibernate
JPA stands for Java Persistence API is a specification that is used to access, manage, and persist data between Java objects and relational databases and is widely considered a standard approach for Object Relational Mapping.
Hibernate is a Java framework used to store Java objects in the relational database system. It is an implementation of JPA and hence, it follows the common standards provided by JPA.
Micronaut with JPA Hibernate
We can use the Micronaut framework to build an application for accessing data from the database with the use of JPA Hibernate. The example below shows the implementation of this:
1.We can directly make a Micronaut application using the below command:
mn create-app example.micronaut.micronaut-jpa-hibernate --build=maven --lang=java
where “example.micronaut.micronaut-jpa-hibernate” is the app name.
2. Now, let’s start the actual coding part by creating one Controller, Repo, RepoImpl, Entity, and the following Test Cases:
Entity Class (also add the following Getters and Setters, Constructors, etc):
Now run the project locally and we can verify the endpoints using postman.
Hence, we have covered the Micronaut Framework using JPA Hibernate with an example.