Add hibernate-demo: get() vs load(), merge() vs refresh(), inserting objects (Hibernate 7.4.1.Final + Spring Boot 4.1.0)
This commit is contained in:
47
scripts/clean_output.py
Executable file
47
scripts/clean_output.py
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Turn a raw mvn spring-boot:run capture into a clean, reproducible transcript.
|
||||
|
||||
Strips JVM/build noise (sun.misc.Unsafe warnings, JAVA_TOOL_OPTIONS proxy banners) and the
|
||||
duplicate un-prefixed echo of each SQL statement that org.hibernate.SQL's show_sql=true prints
|
||||
to stdout in addition to the "Hibernate: ..." line the logger emits -- same text twice, so only
|
||||
the logger-prefixed copy is kept.
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
|
||||
DROP_PREFIXES = (
|
||||
"WARNING:",
|
||||
"Picked up JAVA_TOOL_OPTIONS",
|
||||
)
|
||||
|
||||
|
||||
def clean(lines):
|
||||
out = []
|
||||
for line in lines:
|
||||
stripped = line.rstrip("\n")
|
||||
if any(stripped.startswith(p) for p in DROP_PREFIXES):
|
||||
continue
|
||||
# Drop the bare SQL echo line that show_sql=true prints without the "Hibernate: " prefix
|
||||
# -- it is always immediately followed by the same text WITH the prefix.
|
||||
out.append(stripped)
|
||||
deduped = []
|
||||
i = 0
|
||||
while i < len(out):
|
||||
cur = out[i]
|
||||
nxt = out[i + 1] if i + 1 < len(out) else None
|
||||
if nxt is not None and nxt == "Hibernate: " + cur:
|
||||
i += 1 # skip the bare echo, keep the prefixed one on the next iteration
|
||||
continue
|
||||
deduped.append(out[i])
|
||||
i += 1
|
||||
return deduped
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
src, dst = sys.argv[1], sys.argv[2]
|
||||
with open(src, encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
cleaned = clean(lines)
|
||||
with open(dst, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(cleaned) + "\n")
|
||||
print(f"{src}: {len(lines)} -> {dst}: {len(cleaned)} lines")
|
||||
Reference in New Issue
Block a user