Spring Data JPA: @OneToMany Annotation

In this post, We will take a look at one to many mapping with spring data jpa. With a simple spring boot application, we will walkthrough through how to implement @OneToMany annotation the right way. One To Many Relationship mapping In the object-relational model, the One-To-Many relationship refers to One parent entity that has a…

Spring Data JPA @ManyToOne Annotation

Let us learn how to use @ManyToOne annotation in Spring Data JPA with a spring boot application as an example. What is Many To One Relationship? The many-to-one mapping or association means that one parent record can have multiple child records. In other words, multiple records of a table can associate themselves with a common…

Introduction to Spring Data JPA

The Spring JPA ( also known as spring Data JPA) is one of the spring modules that deal with storing, retrieving, and searching entity objects. In this post, we will take a look at spring JPA in detail using the spring boot application. Introduction Spring Data JPA revolves around the org.springframework.data.repository.Repository interface. This interface acts…

Connection to a database from Spring Boot

Spring Boot lets you make connections to a database of any type with little to no configuration. In this post, we will see how to connect to a MySQL database with spring boot. Step 1: Add a database starter In spring boot, a starter is a special type of dependency that comes with some auto-configuration….

Replacing Tomcat with Undertow in Spring Boot

In this post, we will learn how to replace Tomcat with Undertow in Spring Boot with an example. What is Undertow? Undertow is the new embeddable web server written in Java. It has great HTTP2 support, it provides blocking and not blocking APIs based in Java NiO. And most importantly, the undertow is lightweight. Replace…

Jetty with Spring Boot – Replacing tomcat with Jetty

Let’s learn how to change the default tomcat server with a jetty server in Spring boot with detailed instructions. Tomcat and Jetty are the most known web servers in Java. They both have identical features and have the same set of features to offer. Even though I personally prefer tomcat, there are ways to update…

Whitelabel Error Page in Spring Boot | Complete Guide

Let’s learn about the Whitelabel error page in Spring Boot and how to customize or disable them. White label error pages are default behavior from Spring Boot. Like any other feature, We can customize this feature to great extent. What are Whitelabel error pages in Spring Boot? Depending on API client request or browser request,…

Customizing Exit Codes of a Spring Boot Application

Let’s take a look at exit codes in Spring boot and the various ways we can customize them. What is an Exit Code? In the UNIX shell, An exit code or sometimes known as a return code is a number from 0 to 255 by a process or an executable. These codes let the caller…

Spring Boot Database Initialization

Let’s learn all about database initialization in spring boot. We can create and populate a database in different ways. Even though it is common to do this manually, an automatic approach is not a bad thing. For example, Spring Boot offers Schema and Data initialization through the JPA module. We can control this behavior using…

Export to CSV file using Spring Boot

In this post, let’s look at how easy it is to export information from the database to a CSV file using Spring Boot and JPA. For this example, We are going to download data from tables using Spring JPA and write the response as CSV. Approach To demonstrate the export of data into a CSV…