Add h8-preview module: hibernate-demo suite against Hibernate 8.0.0.Beta3 and Jakarta Persistence 4.0.0-M7

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gth99spB1CzQmBFofXmU4Z
This commit is contained in:
Claude
2026-09-28 08:42:17 +00:00
parent 8568c0ce6c
commit 833f3e1c31
35 changed files with 769 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Compiles each file in src/broken/ against Hibernate 7.4.5.Final and against 8.0.0.Beta3 and keeps the compiler's own words.
# Then compiles BinaryProbe against 7 and runs it on 8 (and the reverse) to show linkage errors.
set -uo pipefail
cd "$(dirname "$0")/.."
W=$(mktemp -d)
cp_for() { mvn -B -q dependency:build-classpath -Dmdep.outputFile="$W/cp-$1.txt" -Dhibernate.version=$2 -Dpersistence.version=$3 >/dev/null 2>&1; cat "$W/cp-$1.txt"; }
CP7=$(cp_for h7 7.4.5.Final 3.2.0); CP8=$(cp_for h8 8.0.0.Beta3 4.0.0-M7)
{
echo "# compile-errors (javac --release 25 -Xlint:removal -Xlint:deprecation; files in src/broken/)"
for f in UsesTransformers UsesReplicate StatelessInsertReturnsId QueryVariable TypedQueryVariable; do
for v in h7 h8; do
CP=$([ $v = h7 ] && echo "$CP7" || echo "$CP8")
mkdir -p "$W/out-$v"
echo "--- $f on $v"
javac --release 25 -Xlint:removal -Xlint:deprecation -proc:none -d "$W/out-$v" -sourcepath src/main/java -cp "$CP" src/broken/$f.java 2>&1 \
| grep -v JAVA_TOOL | sed 's#^src/broken/##' | grep -v -E '^\s*\^?$' || true
done
done
} > output/04-compile-errors.txt
{
echo "# binary-compatibility (BinaryProbe compiled against one Hibernate, run on the other)"
for pair in "h7 h8" "h8 h7"; do
set -- $pair
CPC=$([ $1 = h7 ] && echo "$CP7" || echo "$CP8"); CPR=$([ $2 = h7 ] && echo "$CP7" || echo "$CP8")
rm -rf "$W/bin-$1"; mkdir -p "$W/bin-$1"
javac --release 25 -proc:none -d "$W/bin-$1" -sourcepath src/main/java -cp "$CPC" src/broken/BinaryProbe.java 2>&1 | grep -v JAVA_TOOL
echo "--- compiled on $1, run on $2"
java -cp "$W/bin-$1:$CPR" BinaryProbe 2>&1 | grep -E '^(createQuery ran|Exception in thread|java\.lang\.)' | cut -c1-230 | head -3
done
} > output/05-binary-compatibility.txt
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Facts read from jars: the Jakarta Persistence SPI change and whether Spring implements it.
set -uo pipefail
cd "$(dirname "$0")/.."
W=$(mktemp -d); R="$HOME/.m2/repository"
for a in jakarta.persistence:jakarta.persistence-api:3.2.0 jakarta.persistence:jakarta.persistence-api:4.0.0-M7 org.springframework:spring-orm:7.0.9 org.springframework:spring-orm:7.1.0-M2; do
mvn -B -q dependency:get -Dartifact=$a >/dev/null 2>&1
done
{
echo "# persistence-spi (javap on jakarta.persistence.spi.PersistenceUnitInfo, and on Spring's implementation)"
for v in 3.2.0 4.0.0-M7; do
javap -cp "$R/jakarta/persistence/jakarta.persistence-api/$v/jakarta.persistence-api-$v.jar" jakarta.persistence.spi.PersistenceUnitInfo 2>/dev/null \
| grep -E 'public abstract|public default' | sed 's/^ *//; s/jakarta.persistence.spi.//g; s/java.util.//g; s/java.lang.//g; s/jakarta.persistence.//g' | sort > "$W/spi-$v.txt"
done
echo "--- methods that exist in Jakarta Persistence 4.0.0-M7 but not in 3.2.0"
comm -13 "$W/spi-3.2.0.txt" "$W/spi-4.0.0-M7.txt" | sed 's/^/ /'
for v in 7.0.9 7.1.0-M2; do
echo "--- org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo $v: methods mentioning those names"
all=$(javap -cp "$R/org/springframework/spring-orm/$v/spring-orm-$v.jar" org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo 2>/dev/null | grep -c '(' || true)
n=$(javap -cp "$R/org/springframework/spring-orm/$v/spring-orm-$v.jar" org.springframework.orm.jpa.persistenceunit.SpringPersistenceUnitInfo 2>/dev/null | grep -c -E 'AllPackageDescriptors|DefaultToOneFetchType|AllClassNames|ModuleDescriptors|ManagedPackageDescriptors' || true)
echo " class found, $all methods and constructors listed; matches for the six new names: $n"
done
} > output/06-persistence-spi.txt
{
echo "# dependency-versions (hibernate-core 8.0.0.Beta3 POM: what it declares)"
curl -s https://repo1.maven.org/maven2/org/hibernate/orm/hibernate-core/8.0.0.Beta3/hibernate-core-8.0.0.Beta3.pom \
| grep -B1 -A2 -E '<artifactId>(hibernate-models|jakarta.persistence-api|byte-buddy|jandex)</artifactId>' | grep -E 'artifactId|version' | sed 's/^ *//' | paste -sd' ' - | sed 's#</version>#</version>\n#g' | sed 's/^ *//' | grep -v '^$'
} > output/07-hibernate-core-pom.txt
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Regenerates every file under output/. Needs JDK 25, Maven 3.9 and network access to Maven Central.
# ./scripts/run-all.sh
# 01-03: the plain-Hibernate tests on 8.0.0.Beta3, then on 7.4.5.Final (mvn clean between, or stale classes link wrongly)
# 04-07: javac / javap / POM facts. suite-*.txt: the whole ../src suite in a scratch copy, four ways (slow, ~10 minutes).
set -euo pipefail
cd "$(dirname "$0")/.."
mvn -B clean test
mvn -B clean test -Dhibernate.version=7.4.5.Final -Dpersistence.version=3.2.0 -Dh.label=h7
./scripts/capture-compile-errors.sh
./scripts/capture-facts.sh
./scripts/run-suite.sh h7
./scripts/run-suite.sh h8-unpinned 8.0.0.Beta3 4.0.0-M7 no
./scripts/run-suite.sh h8-pinned 8.0.0.Beta3 4.0.0-M7 yes
./scripts/run-suite.sh h8-boot42 8.0.0.Beta3 4.0.0-M7 yes 4.2.0-M2
ls -1 output
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Runs the whole hibernate-demo suite (../src) against a chosen Hibernate / Jakarta Persistence pair in a
# scratch copy, and writes a plain-text summary. The original tree is never touched.
#
# ./scripts/run-suite.sh <label> [hibernate.version jakarta-persistence.version]
# ./scripts/run-suite.sh h7 # what Spring Boot 4.1.1 manages
# ./scripts/run-suite.sh h8 8.0.0.Beta3 4.0.0-M7 # Hibernate 8 beta
set -uo pipefail
HERE="$(cd "$(dirname "$0")/.." && pwd)"
LABEL="${1:?label}"; HV="${2:-}"; PV="${3:-}"; PIN="${4:-}"; BOOT="${5:-}" # PIN=yes adds the hibernate-models / jandex pins below
W="$(mktemp -d)"
mkdir -p "$W/src" && cp -r "$HERE/../src/." "$W/src/" && cp "$HERE/../pom.xml" "$W/pom.xml"
cd "$W"
[ -n "$BOOT" ] && sed -i "0,/<version>4.1.1<\/version>/s//<version>$BOOT<\/version>/" pom.xml
if [ "$PIN" = yes ]; then
# Maven's nearest-wins rule picks hibernate-models 1.1.1 (through hibernate-search-mapper-orm) over the 1.3.4
# hibernate-core 8 asks for. Pinning is the whole fix for the classpath problem.
python3 - <<'PY'
p=open('pom.xml').read()
pin=""" <dependencyManagement><dependencies>
<dependency><groupId>org.hibernate.models</groupId><artifactId>hibernate-models</artifactId><version>1.3.4</version></dependency>
<dependency><groupId>io.smallrye</groupId><artifactId>jandex</artifactId><version>3.6.0</version></dependency>
</dependencies></dependencyManagement>
"""
open('pom.xml','w').write(p.replace('</project>',pin+'</project>'))
PY
fi
ARGS=(-B -Dmaven.test.failure.ignore=true)
[ -n "$HV" ] && ARGS+=("-Dhibernate.version=$HV")
[ -n "$PV" ] && ARGS+=("-Djakarta-persistence.version=$PV")
OUT="$HERE/output"
mvn "${ARGS[@]}" test-compile > "$W/compile.log" 2>&1; CRC=$?
{
echo "# suite on ${LABEL} hibernate=${HV:-managed by Boot 4.1.1} persistence-api=${PV:-managed by Boot 4.1.1}"
echo "spring boot parent: ${BOOT:-4.1.1}"
echo "pins (hibernate-models 1.3.4, jandex 3.6.0): ${PIN:-no}"
echo "test-compile exit code: $CRC"
} > "$OUT/suite-$LABEL.txt"
if [ $CRC -ne 0 ]; then
grep -E '^\[ERROR\] /' "$W/compile.log" | sed "s#$W/src/##" | sed 's/^\[ERROR\] //' | sort -u > "$OUT/compile-errors-$LABEL.txt"
echo "compile errors: $(wc -l < "$OUT/compile-errors-$LABEL.txt")" >> "$OUT/suite-$LABEL.txt"
else
mvn "${ARGS[@]}" test > "$W/test.log" 2>&1
python3 - "$W" >> "$OUT/suite-$LABEL.txt" <<'PY'
import glob,re,sys,collections
w=sys.argv[1]; t=f=e=s=0; causes=collections.Counter(); classes=set()
for p in sorted(glob.glob(w+'/target/surefire-reports/*.txt')):
x=open(p).read()
m=re.search(r'Tests run: (\d+), Failures: (\d+), Errors: (\d+), Skipped: (\d+)',x)
if not m: continue
a,b,c,d=map(int,m.groups()); t+=a;f+=b;e+=c;s+=d
for blk in re.split(r'\n(?=\S+ -- Time elapsed: [\d.]+ s <<< (?:ERROR|FAILURE)!)',x)[1:]:
cb=re.findall(r'Caused by: ([^\n]*)',blk)
first=blk.split('\n')[1] if '\n' in blk else ''
msg=(cb[-1] if cb else first)
msg=re.sub(r'@[0-9a-f]{5,}','@..',msg)[:170]
if 'failure threshold' in first and not cb: msg='(context failed earlier in the same JVM; see the first failure of that context)'
causes[msg]+=1; classes.add(p.split('/')[-1][:-4].split('.')[-1])
print(f'tests run: {t} failures: {f} errors: {e} skipped: {s}')
print(f'test classes with a problem: {len(classes)}')
print('distinct final causes (count = failing test methods):')
for msg,n in causes.most_common(): print(f' {n:>4} {msg}')
PY
fi
cat "$OUT/suite-$LABEL.txt"