Add multitenancy module: Hibernate 7 @TenantId vs schema-per-tenant (shared pool + search_path, pool per tenant), JWT tenant filter, isolation failure modes on PostgreSQL 17 (Hibernate 7.4.14.Final, Spring Boot 4.1.2)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4VQVEJWetTT1dYzyJ
This commit is contained in:
2026-10-29 05:52:26 +00:00
co-authored by Claude Sonnet 5.5
parent ef2d2aa8ea
commit 98f4ed7411
45 changed files with 1820 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# Regenerates every file under output/. Needs JDK 25, Maven 3.9 with access to Maven Central, and a running Docker daemon
# (Testcontainers starts one postgres:17-alpine container shared by all tests).
set -euo pipefail
cd "$(dirname "$0")/.."
mkdir -p output
CP_FILE="$(mktemp)"
mvn -B -q dependency:build-classpath -Dmdep.outputFile="$CP_FILE" >/dev/null
JAR="$(tr ':' '\n' < "$CP_FILE" | grep 'hibernate-core-')"
BOOT_HIB="$(tr ':' '\n' < "$CP_FILE" | grep 'spring-boot-hibernate-')"
{
echo "# javap of the shipped $(basename "$JAR")"
for c in org.hibernate.annotations.TenantId org.hibernate.context.spi.CurrentTenantIdentifierResolver \
org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider \
org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider \
org.hibernate.cfg.MultiTenancySettings; do
echo; echo "\$ javap -cp $(basename "$JAR") $c"
javap -cp "$JAR" "$c" 2>&1 | grep -v '^Picked up'
done
echo; echo "# javap of $(basename "$BOOT_HIB")"
echo "\$ javap -cp $(basename "$BOOT_HIB") org.springframework.boot.hibernate.autoconfigure.HibernatePropertiesCustomizer"
javap -cp "$BOOT_HIB" org.springframework.boot.hibernate.autoconfigure.HibernatePropertiesCustomizer 2>&1 | grep -v '^Picked up'
echo; echo "# does spring-boot-hibernate mention tenants at all? (entries containing 'tenant', case-insensitive)"
rm -rf "$CP_FILE.d"; mkdir "$CP_FILE.d"; (cd "$CP_FILE.d" && unzip -q "$BOOT_HIB")
echo "matching files: $(grep -rli tenant "$CP_FILE.d" | wc -l)"
rm -rf "$CP_FILE.d"
} > output/00-javap.txt
rm -f "$CP_FILE"
mvn -B clean test
ls -1 output