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,46 @@
package com.ankurm.hibernatedemo.mappingstyle;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.ankurm.hibernatedemo.HibernateDemoApplication;
import org.hibernate.AnnotationException;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
/**
* <xml-mapping-metadata-complete/> makes Hibernate IGNORE ALL annotations for this
* persistence unit -- not just the ones a matching orm.xml entry overrides. OverrideEntity
* carries @Id/@GeneratedValue on "id" in Java, but the metadata-complete orm.xml entry only
* declares <basic name="value"> and omits <id> entirely. Result: bootstrap fails because
* the (ignored) @Id annotation no longer counts -- proving metadata-complete is not just an
* override switch, it is a full annotation kill-switch for the persistence unit.
*
* <p>Docs: docs/04-annotations-vs-xml.md, Topic 1.
*/
class XmlMappingMetadataCompleteTest {
@Test
void metadataComplete_ignoresAtIdAnnotation_bootFailsWithNoIdentifier() {
SpringApplicationBuilder builder = new SpringApplicationBuilder(HibernateDemoApplication.class)
.properties("spring.jpa.mapping-resources=orm-xml-metadata-complete.xml");
BeanCreationException ex = assertThrows(BeanCreationException.class, () -> {
try (ConfigurableApplicationContext ctx = builder.run()) {
// never reached
}
});
Throwable root = ex;
while (root.getCause() != null) {
root = root.getCause();
}
System.out.println("RESULT[metadata-complete]: boot FAILED as predicted: " + root.getClass().getName()
+ ": " + root.getMessage());
assertThat(root).isInstanceOf(AnnotationException.class);
assertThat(root.getMessage()).contains("has no identifier");
}
}