Spring Data JPA @Modifying Annotation 1. Introduction In this short tutorial, we’ll learn how to create update queries with the Spring Data JPA @Query annotation. We’ll achieve this by using the @Modifying annotation. First, we’ll refresh our memory and see how to make queries using Spring Data JPA. After that,… Continue Reading spring-data-jpa-modifying-annotation

A Spring Custom Annotation for a Better DAO Spring Persistence Spring Annotations 1. Overview In this tutorial, we’ll implement a custom Spring annotation with a bean post-processor. So how does this help? Simply put – we can reuse the same bean instead of having to create multiple, similar beans of… Continue Reading spring-annotation-bean-pre-processor

Running Setup Data on Startup in Spring 1. Introduction In this article we’ll focus on how to run logic at the startup of a Spring application. Further reading: Configure a Spring Boot Web Application Some of the more useful configs for a Spring Boot application. Read more → Spring Boot:… Continue Reading running-setup-logic-on-startup-in-spring

Self-Contained Testing Using an In-Memory Database 1. Overview In this tutorial, we’re going to create a simple Spring application which relies on an in-memory database for testing. For the standard profile, the application will have a standalone MySQL database configuration, which requires having the MySQL server installed and running, with… Continue Reading spring-jpa-test-in-memory-database

The Exists Query in Spring Data 1. Introduction In many data-centric applications, there might be situations where we need to check whether a particular object already exists. In this tutorial, we’ll discuss several ways to achieve precisely that using Spring Data and JPA. 2. Sample Entity To set the stage… Continue Reading spring-data-exists-query

Access the Same In-Memory H2 Database in Multiple Spring Boot Applications 1. Overview In this quick tutorial, we’ll demonstrate how to access the same in-memory H2 database from multiple Spring Boot applications. To do this, we’ll create two distinct Spring Boot applications. The first Spring Boot application will start an in-memory H2… Continue Reading spring-boot-access-h2-database-multiple-apps

Spring Boot with Multiple SQL Import Files 1. Overview Spring Boot allows us to import sample data into our database – mainly to prepare data for integration tests. Out of the box, there are two possibilities. We can use import.sql (Hibernate support) or data.sql (Spring JDBC support) files to load… Continue Reading spring-boot-sql-import-files