Skip to main content

Java Web App with Quarkus and JPAStreamer

About 3 minJavaQuarkuscrashcoursefreecodecampjavajdkjdk8streamquarkusjpajpastreamer

Java Web App with Quarkus and JPAStreamer ๊ด€๋ จ


Get started with Quarkus and JPAStreamer

In the world of software development, innovation often arrives in the form of powerful tools that transform the way we build applications - enter Quarkus, a development platform that's reshaping the Java landscape.

In the world of software development, innovation often arrives in the form of powerful tools that transform the way we build applications - enter Quarkus, a development platform that's reshaping the Java landscape.

If you are new to the Quarkiverse, this tutorial is a great way to start exploring how it can radically improve your Java development experience. Iโ€™ll show you how to quickly assemble a REST application on the Quarkus platform, leveraging the power of JPAStreamer, a Hibernate extension to handle database interactions with the elegance of the Java Stream API.

By the end of this walkthrough, you'll possess the know-how to seamlessly streamline your forthcoming Java applications for cloud deployment. Moreover, I wouldn't be surprised if you discover that Java is far more enjoyable with live code reloads and continuous testing.

In this course, you'll learn how to use Quarkus and JPAStreamer to build a REST web application. Quarkus is an open-source framework tailored for Java, optimized for building speedy cloud-native microservices and serverless applications, especially in containerized environments like Kubernetes. JPAStreamer, on the other hand, is a Java library that simplifies database interactions by allowing JPA entities to harness the expressiveness of Java Stream operations.


What Weโ€™ll Build

This tutorial serves as a comprehensive guide to building a robust Quarkus application. We'll cover every essential aspect, from setting up your development environment and establishing a database connection, to defining REST endpoints, mastering Java Streams with JPAStreamer for powerful queries, effortless continuous testing, and achieving native compilation. The final result is a lightweight REST application that serves information from a sample Film in a split second after a cold start, laying the groundwork for your future Quarkus projects.

On the surface, this looks like yet another guide on how to develop an application, but in practice, it is also a glimpse into what developing with Quarkus feels like.

During the development, you will become familiar with the following topics:

  • Setting up a Quarkus project
  • Connecting to a MySQL Docker instance
  • Using the Quarkus development mode
  • Expressing queries as Java Streams with JPAStreamer
  • Performing continuous testing
  • Compiling the application natively for rapid start-up times and minimal memory consumption

What Makes Quarkus Special?

Quarkus is often described as a cutting-edge, cloud-native framework designed for modern Java and Kotlin applications. Its mission is to tackle longstanding Java challenges, such as prolonged start-up times, high memory consumption, and a rather slow development experience.

It is able to achieve this objective with two clever design feats - an improved build process that performs much of the heavy lifting at build time instead of application start-up, and as an extension of that - a developer mode that allows you to spin up your application and incorporate any code updates on the fly.

Four years after its initial release, Quarkus boasts a wide range of extensions, ensuring seamless integration with all the major Java libraries like Hibernate, Spring, and JUnit.

What is JPAStreamer?

JPAStreamer is a lightweight library designed to simplify database access in Java applications that utilizes the Java Persistence API (JPA). Its power lies in its expressive and type-safe Stream queries that help enhance coding precision and productivity.

JPAStreamer optimizes performance by translating pipelines into Hibernate Query Language (HQL) queries. Unlike using getResultStream() in Hibernate, which materializes all entities, JPAStreamer ensures only relevant entities are fetched, akin to using SQL directly.

Imagine fetching 10 films from a database where each title starts with "A" and is at least 1 hour long. With JPAStreamer, the query is as simple as:

List<Film> films = jpaStreamer.stream(Film.class)
	.filter(Film$.title.startsWith("A")
	.and(Film$.length.greaterThan(60))
	.limit(10)
	.collect(Collectors.toList());

Prerequisites

Before we roll up our sleeves and start coding, it's important to ensure you have everything you need in place. Even though the walkthrough covers any details necessary to get a fully functional application, it is assumed that you are:

  • Familiar with Basic Java
  • Acquainted with the Java Stream API
  • Comfortable with Database Interactions using JPA/Hibernate

If you're planning to follow along on your local machine, make sure your development environment meets the following requirements:


Table of Contents


References


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.