Stage 2 console classes and the shared LoanPolicy, then a Spring Boot 4.1.2 + JPA API (H2, @Version optimistic locking, problem+json errors). Tests write output/ transcripts while asserting the same numbers; scripts regenerate everything. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4DPL6dtpFg4U4LHc2
18 lines
1.0 KiB
Bash
Executable File
18 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Starts the API with Hibernate SQL logging, performs one borrow, and prints only the SQL that
|
|
# the borrow produced. Look for "version" in the UPDATE: that is optimistic locking at work.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
mvn -B -q -DskipTests package
|
|
LOG=/tmp/library-sql.log
|
|
setsid nohup java -jar target/library-management-1.0.0.jar --server.port=8081 --logging.level.org.hibernate.SQL=DEBUG > "$LOG" 2>&1 < /dev/null &
|
|
for _ in $(seq 1 60); do curl -s -o /dev/null localhost:8081/api/books && break; sleep 1; done
|
|
J='Content-Type: application/json'
|
|
curl -s -o /dev/null -H "$J" -d '{"isbn":"978-0134685991","title":"Effective Java","author":"Joshua Bloch","copies":2}' localhost:8081/api/books
|
|
curl -s -o /dev/null -H "$J" -d '{"name":"Asha","email":"[email protected]"}' localhost:8081/api/members
|
|
START=$(wc -l < "$LOG")
|
|
curl -s -o /dev/null -H "$J" -d '{"memberId":1,"bookId":1}' localhost:8081/api/loans
|
|
sleep 1
|
|
tail -n +"$((START + 1))" "$LOG" | grep 'org.hibernate.SQL' | sed -E 's/^.*org.hibernate.SQL +: //'
|
|
scripts/stop.sh
|