Add Hibernate 7 batches 2-6 and batch 7: mapping styles, JPA annotations, natural IDs, @Immutable, stored procedures, in-memory test databases, JNDI mocking, proxies, associations, temporal mapping, named queries, HQL, Criteria API, EntityManager bootstrapping, Ehcache 3 L2 cache configuration, HikariCP connection pooling, and Hibernate Validator CDI integration (Hibernate 7.4.5.Final + Spring Boot 4.1.1 + JDK 25)
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EQNA6DJ9VgCtW6zhCE8Xud
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.ankurm.hibernatedemo.testdb;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Backs docs/09-testing-in-memory-databases.md, chapter "Startup time, with the caveat this is a shared
|
||||
* container". NOT a benchmark -- three runs per database, plain {@code System.nanoTime()},
|
||||
* one shared, likely-noisy sandbox container. The numbers are indicative of relative order of
|
||||
* magnitude only, and the docs/output file this writes says so explicitly.
|
||||
*/
|
||||
class StartupTimingTest {
|
||||
|
||||
private static final Logger DEMO = LoggerFactory.getLogger("DEMO");
|
||||
|
||||
private long timeOneBuild(TestDbSupport.Db db, String suffix) {
|
||||
long start = System.nanoTime();
|
||||
SessionFactory sf = TestDbSupport.buildSessionFactory(db, suffix, "create-drop", TestDbWidget.class);
|
||||
long elapsedMs = (System.nanoTime() - start) / 1_000_000;
|
||||
sf.close();
|
||||
return elapsedMs;
|
||||
}
|
||||
|
||||
@Test
|
||||
void measureStartupAcrossThreeRunsPerDatabase() {
|
||||
TestDbSupport.Db[] dbs = {TestDbSupport.Db.H2, TestDbSupport.Db.HSQLDB, TestDbSupport.Db.DERBY};
|
||||
for (TestDbSupport.Db db : dbs) {
|
||||
long[] times = new long[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
times[i] = timeOneBuild(db, "timing" + i);
|
||||
}
|
||||
DEMO.info("startup ms for {} over 3 runs: {}, {}, {} (sandbox container -- indicative only, not a benchmark)",
|
||||
db, times[0], times[1], times[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user