Notes & guides

Blog

Posts about software, Java, Spring, and community.

$ docker compose up -d
$ docker compose ps
api    running  :8080
db     healthy  :5432
redis  running  :6379
November 26, 2026javaspring

Testing Spring Boot and JPA with Testcontainers

Testing against real PostgreSQL instead of H2: @ServiceConnection, @DataJpaTest, Flyway migrations, an N+1 regression test by counting queries, container reuse and running the app locally with containers.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 25, 2026javaspring

RAG with Spring AI and PostgreSQL pgvector

An app that answers questions over your own documents: generating embeddings with Spring AI, storing them in pgvector, similarity search, and enriching the prompt with QuestionAnswerAdvisor.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 24, 2026javaspring

Tool Calling and MCP with Spring AI

Exposing your application's functions to an LLM with Spring AI — tool calling with @Tool, ToolContext, returnDirect, security, and setting up a Model Context Protocol (MCP) server and client.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 23, 2026javaspring

Getting Started with Spring AI: ChatClient, Prompts, Structured Output and Chat Memory

Adding LLM support to a Spring Boot app with Spring AI — setup, the ChatClient API, prompt templates, structured output into records, streaming and conversation memory.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 22, 2026javaspring

@Transactional Pitfalls and Locking with Spring and Hibernate

How @Transactional works through proxies, self-invocation, rollback rules, propagation, readOnly, optimistic and pessimistic locking, and the SKIP LOCKED job-queue pattern.

$ javac Main.java
$ java Main
Hello, World!
November 21, 2026javahibernate

Solving the N+1 Query Problem in Hibernate and Spring Data JPA

How to detect the N+1 query problem and fix it with JOIN FETCH, @EntityGraph, @BatchSize, SUBSELECT and DTO projections — a practical guide with examples.

$ javac Main.java
$ java Main
Hello, World!
November 20, 2026javahibernate

JPA and Hibernate Entity Mapping Best Practices

What to watch for when designing entities with Hibernate 7 and Spring Boot — ID strategies and batching, LAZY associations, bidirectional mappings, equals/hashCode, @Version, auditing and schema management.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 19, 2026javaspring

Virtual Threads in Spring Boot with Java 25

Enabling virtual threads in Spring Boot, how Java 24+ fixed the pinning problem, the connection-pool bottleneck, scoped values, structured concurrency and observability tips.

$ ./mvnw spring-boot:run
Tomcat started on :8080
Started Application
November 18, 2026javaspring

Spring Boot 4 and Spring Framework 7: What's New and How to Migrate

The main changes in Spring Boot 4 and Spring Framework 7 — Jakarta EE 11, modular auto-configuration, JSpecify null-safety, API versioning, HTTP service clients, built-in resilience, Jackson 3 and the steps to migrate from 3.5.