Files
asmhatre 448c383879 Add jdbc-vs-jpa module: Spring Data JDBC vs JPA on a shared Order aggregate
Same Customer/Order/OrderItem domain modelled with Hibernate/Spring Data JPA and
Spring Data JDBC side by side, both running through a shared StatementLoggingDataSource
so SQL-statement counts are directly comparable. 11 tests, 11 captured transcripts,
6 doc chapters. Companion repo for the ankurm.com article on when to drop the ORM.
2026-09-17 19:09:35 +00:00

31 lines
936 B
Java

package com.ankurm.jdbcvsjpa;
import com.ankurm.jdbcvsjpa.support.SqlLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* Dumps the real SQL statement log for whatever ran in this JVM since the last reset — the
* same mechanism the tests use to write docs/output transcripts, exposed so you can point it
* at your own scenario. Delete this before shipping; it is a diagnostic, not a feature. See
* docs/03-the-sql-log.md.
*/
@RestController
public class DiagController {
private final SqlLog sqlLog;
public DiagController(SqlLog sqlLog) {
this.sqlLog = sqlLog;
}
@GetMapping("/diag/sql-log")
public Map<String, Object> sqlLog() {
List<String> statements = sqlLog.statements();
return Map.of("count", statements.size(), "statements", statements);
}
}