Building Reactive Java Applications with Spring Framework

If you’re a Java developer who uses the Spring ecosystem, you’ve probably seen the Spring Pet Clinic. In this workshop, we will walk you through a new reactive implementation of the Pet Clinic backend that uses Spring WebFlux and Apache Cassandra® (via DataStax Astra DB).

The cloud-native database-as-a-service built on Cassandra fits the highly concurrent, non-blocking nature of our reactive application. We’ll do all of our work in the cloud with Gitpod’s open-source, zero-install and collaborative development environment.

Spring Boot: Nice and Easy [Video]

Ever looked for a comprehensive intro to Spring Boot that is fun and entertaining at the same time? Then have a look at this brand-new episode of the "Marco Codes" YouTube channel: Spring Boot - Nice & Easy.

In this video, we will build a tiny Google Photos-like clone with Spring Boot. Additionally, along the way, you'll learn plenty about Spring's Dependency Injection and MVC frameworks, Validation and File Handling, Spring Data and Databases, and you'll even deploy your application at the end. 

Framewars: The Battle Between NoSQL and Java in the Cloud Arena

This lecture's objective is to make comparisons between points and weaknesses of Java frameworks that integrate with databases. On the one hand, the NoSQL MongoDB, Redis, Neo4J, and Cassandra, and on the other, the Java frameworks that integrate with them: Spring, Quarkus, Jakarta EE, Micronaut. The arena: the cloud! In this ring, the one who best analyzes each tool's trade-offs wins in this epic battle.

Microservices Annotator Plugin

Writing microservices has never been easy and does not become easier with growing codebases. All the complexity strives from tons of interactions between the moving parts of your applications.

And then we had this year's holidays and I had enough free time to think about it. Many complex measures can be used to make the code of microservices more readable, numerous expressive APIs, modern languages, we already use all of these, but the situation does not get better.

WebFlux and Spring Data Example for Java Records

Traditionally, Java developers have depended on constructors, accessors, equals(), hashCode(), and toString() to define classes for basic aggregation of values. However,  this is an error-prone approach that adds little value and diverts attention away from modeling immutable data. Java records were initially offered as a preview in JDK 14 to simplify writing data carrier classes. The second preview was released in JDK 15, and the final version in JDK 16. The JDK Enhancement Proposal JEP 395 has a summary of this history.

While code generators can help reduce boilerplate code, the Java record proposals focus on the semantics of the code. Let's look at the characteristics and benefits of Java records and how to use them to develop a REST API and query a database.

Improving Backend Performance, Part 3/3: Fast Analytics

Analytics involves the computation of data to find patterns. From simple calculations - such as the sum of values or its average to statistics calculated with machine learning algorithms, analytics frequently deals with big amounts of data that need to be processed as fast as possible.

We saw in the previous part of this series of articles, how indexes help to improve the speed of database operations. And in all honesty, the problem in the laboratory application shown in this article can be solved by merely adding an index. However, in real-world applications with many tables that have a lot of columns, dealing with indexes can become difficult. In this article, I explore one interesting technology that helps with analytic SQL queries: ColumnStore using Spring Boot and Vaadin Flow.

Understanding JPA and Other Query Construction Frameworks

JPA is the standard that guides the developer towards an object conceptualization of his application and provides him with an abstraction of the relational model. However, once the model is in place, several frameworks are available to generate the request or the command. Which choices are the most relevant? Let's explore.

Criteria JPA2

Once your dependencies are added, the Criteria API is immediately available. It is the most basic and requires knowing the API and its subtleties to produce requests. The use of these objects obliges to pass directly in character string the name of the attributes in order to impose restrictions. Errors are therefore quite frequent during development and during refactoring operations. Plus, because these errors happen at run time, they are often caught too late.

Introduction to Spring Data Elasticsearch 4.1

Preface

I was recently playing around with Spring Data Elasticsearch (the Spring Data project for Elasticsearch) and came across several issues. One of these was a lack of up-to-date articles. This led me to share my experience using the latest Elasticsearch 7 and Spring Data Elasticsearch 4.1. I hope that my advice can help others gain insight into the tool and how to effectively use it for a variety of reasons.

In this Article, You Will Learn

  • What Elasticsearch and Spring Data Elasticsearch are.
  • Basic Elasticsearch cluster setup via Docker (including management and monitoring tool).
  • How to configure Spring Data Elasticsearch in a project.
  • How to use Spring Data Elasticsearch to upload and access Elasticsearch data.
  • What are some pitfalls related to Elasticsearch usage?

First, I will briefly explain the purpose of Elasticsearch.

Spring Data: Easy MongoDB Migration Using Mongock

In one of my projects, I was looking for some simple options to manage MongoDB database schema changes similar to other projects like Flyway or Liquibase. I found Mongock, which is an open-source Java MongoDB tool.

Prerequisites

  • Spring Boot 2.5.0
  • Maven 3.6.1
  • JAVA 11
  • Mongo 4.4

Getting Started

We will start by creating a simple Spring Boot project from start.spring.io, with the following dependencies: Web, MongoDB, and Lombok.

Introduction to Spring Boot and JDBCTemplate: Refactoring to SpringData JPA

Refactoring is the process of modifying a software system without changing its desirable behavior. It was necessary to have an application integrated with the relational database using the Spring JDBC Template in the first parts. The Spring JDBC Template is a powerful tool that facilitates productivityHoweverthere is a way to simplify the code even further with Spring Data JPA. The purpose of this post is to refactor the project to use Spring Data JPA.

Spring Data JPApart of the larger Spring Data family, makes it easy to implement JPA-based repositories easilyThis module deals with enhanced support for JPA-based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.

JPA Goes Even Easier With its Buddy

So, Hello World... After almost a year of development, the first version of JPA Buddy has finally been released! This is a free tool that is supposed to become your faithful coding assistant for projects with JPA and everything related: Hibernate, Spring Data, Liquibase, and other mainstream stacks.

"Why would I use it?" - this is a fair question towards any new tool or framework. In short, if you use JPA for data persistence, JPA Buddy will help you to be more efficient. In this article, I'll present an overview of the tool. I hope it will take its fair place among the most loved tools for Java developers, ones who use JPA, Spring, Liquibase, and of course the most advanced Java IDE - IntelliJ IDEA.

Manage Hierarchical Data in MongoDB With Spring

Introduction

Modeling Tree Structures is one of the most common requirements often met in software applications. Depending on the size of the data, the information each node keeps, the type of queries performed, and the database storage engines available (or allowed), there are plenty of options to evaluate and choose from.

MongoDB allows various ways to use tree data structures to model large hierarchical or nested data relationships such as [1]:

Spring Data: Data Auditing Using JaVers and MongoDB

Recently I was looking for some simple options to track all changes to entities in all my microservices. After researching, I discovered the Java library named JaVers. It is designed as a framework for auditing changes in object-oriented data.

In this post, we’ll see how to use JaVers in a simple Spring Boot application and MongoDB environment to track changes of entities.

Transaction Savepoints in Spring JDBC

Savepoints allow you to create markers within a transaction that you can rollback to, without preventing the transaction from being committed at a later point. These can be treated like intermediate transactions within a single overarching transaction. At the end of the day, you either commit the transaction and persist all the changes to the database or rollback everything. Using savepoints, you can handle potential database errors and return to a safe point within the transaction and carry on.

This post will look at how you can use savepoints within Spring JDBC.

Why Set Is Better Than List in @ManyToMany

In this article, we'll highlight the performance penalties involves by using List or Set in @ManyToMany relationships. We use Spring Data JPA with the default persistence provider, therefore with Hibernate JPA.

First of all, keep in mind that Hibernate deals with @ManyToMany relationships as two unidirectional @OneToMany associations. The owner-side and the child-side (the junction table) represents one unidirectional @OneToMany association. On the other hand, the non-owner-side and the child-side (the junction table) represent another unidirectional @OneToMany association. Each association relies on a foreign key stored in the junction table.