Blog Archive for April 2, 2020

JPA Auditing

April 2, 2020

Spring Boot and JPA contain some features that will automatically record audit changes to Entities. I needed to make the following changes to my application to get this to work:

The application needed the @EnableApaAuditing annotation :::java package com.drumcoder.diary;

import org.modelmapper.ModelMapper;
import org.springframework …

JPA Entities

April 2, 2020

This post covers how to define a JPA entity in a Spring Boot application. Getter and setter methods have been excluded from this example.

import java.time.LocalDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.envers.AuditOverride …

Spring Boot JPA Repositories

April 2, 2020

Spring Boot JPA Repositories allow access to the database at an abstracted level, with queries being written in JPQL.

At their simplest, they look like this:

    /**
     * Find a calendar day given a room and a date.
     *
     * @param calendarDate The date to find the calendar day for …

JWT Security with Azure in Spring Boot

April 2, 2020

I wanted to have my users authenticate with Azure, and create a JWT which then gets passed into each subsequent request to identify them.

First up we have a filter which we add to the request chain. This filter: Picks out a correlation id from the x-correlation-id request header and …