Add Hibernate 7 batches 2-6, batch 7, and batch 8: 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, Hibernate Validator CDI integration, aggregate functions, sorting, pagination, interceptors, and Hibernate Search 8 (Hibernate 7.4.5.Final + Spring Boot 4.1.1 + JDK 25)

This commit is contained in:
2026-09-20 06:06:42 +00:00
committed by Claude
commit 8568c0ce6c
330 changed files with 23668 additions and 0 deletions
@@ -0,0 +1,79 @@
package com.ankurm.hibernatedemo.mappingstyle;
import org.hibernate.SessionFactory;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.MappingSettings;
import org.junit.jupiter.api.Test;
/**
* Empirical probe: what does Hibernate 7.4.5.Final actually do with a legacy
* {@code .hbm.xml} mapping file, bypassing Spring entirely so every setting is explicit.
*
* <p>Docs: docs/04-annotations-vs-xml.md, Topic 1.
*/
class HbmXmlBootTest {
private StandardServiceRegistry baseRegistry() {
return new StandardServiceRegistryBuilder()
.applySetting("hibernate.connection.driver_class", "org.h2.Driver")
.applySetting("hibernate.connection.url", "jdbc:h2:mem:hbmtest;DB_CLOSE_DELAY=-1")
.applySetting("hibernate.connection.username", "sa")
.applySetting("hibernate.connection.password", "")
.applySetting("hibernate.hbm2ddl.auto", "create")
.build();
}
@Test
void defaultSettings_bootingWithHbmXml_printsWhatHappens() {
StandardServiceRegistry registry = baseRegistry();
try {
Metadata metadata = new MetadataSources(registry)
.addResource("com/ankurm/hibernatedemo/mappingstyle/HbmEmployee.hbm.xml")
.buildMetadata();
SessionFactory sf = metadata.buildSessionFactory();
System.out.println("RESULT[default]: BOOT SUCCEEDED, SessionFactory built without hibernate.transform_hbm_xml.enabled");
sf.close();
} catch (Throwable t) {
System.out.println("RESULT[default]: BOOT FAILED: " + t.getClass().getName() + ": " + t.getMessage());
Throwable cause = t.getCause();
while (cause != null) {
System.out.println("RESULT[default]: caused by: " + cause.getClass().getName() + ": " + cause.getMessage());
cause = cause.getCause();
}
} finally {
StandardServiceRegistryBuilder.destroy(registry);
}
}
@Test
void transformHbmXmlEnabled_bootingWithHbmXml_printsWhatHappens() {
StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.applySetting("hibernate.connection.driver_class", "org.h2.Driver")
.applySetting("hibernate.connection.url", "jdbc:h2:mem:hbmtest2;DB_CLOSE_DELAY=-1")
.applySetting("hibernate.connection.username", "sa")
.applySetting("hibernate.connection.password", "")
.applySetting("hibernate.hbm2ddl.auto", "create")
.applySetting(MappingSettings.TRANSFORM_HBM_XML, "true")
.build();
try {
Metadata metadata = new MetadataSources(registry)
.addResource("com/ankurm/hibernatedemo/mappingstyle/HbmEmployee.hbm.xml")
.buildMetadata();
SessionFactory sf = metadata.buildSessionFactory();
System.out.println("RESULT[transform=true]: BOOT SUCCEEDED, SessionFactory built WITH " + MappingSettings.TRANSFORM_HBM_XML + "=true");
sf.close();
} catch (Throwable t) {
System.out.println("RESULT[transform=true]: BOOT FAILED: " + t.getClass().getName() + ": " + t.getMessage());
Throwable cause = t.getCause();
while (cause != null) {
System.out.println("RESULT[transform=true]: caused by: " + cause.getClass().getName() + ": " + cause.getMessage());
cause = cause.getCause();
}
} finally {
StandardServiceRegistryBuilder.destroy(registry);
}
}
}