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,61 @@
package com.ankurm.hibernatedemo.persistenceannotations;
import jakarta.persistence.Entity;
import jakarta.persistence.Enumerated;
import jakarta.persistence.EnumType;
import jakarta.persistence.EnumeratedValue;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
/**
* {@code @EnumeratedValue} is NEW in Jakarta Persistence 3.2 (confirmed present via javap on
* jakarta.persistence-api 3.2.0 -- it does not exist in 3.1). It lets an enum control its own
* persisted representation (a custom code), instead of ORDINAL or STRING.
*
* <p>Docs: docs/05-jpa-persistence-annotations.md, Topic 2.
*/
@Entity
public class EnumeratedValueEntity {
@Id
@GeneratedValue
private Long id;
// @EnumeratedValue's own field type (String) determines the persisted column type, but
// Hibernate still needs to be told this is a STRING-shaped enum, not the ORDINAL default --
// otherwise boot fails with "@EnumeratedValue for EnumType.ORDINAL must be placed on a
// field whose type is byte, short, or int".
@Enumerated(EnumType.STRING)
private Priority priority;
public EnumeratedValueEntity() {
}
public EnumeratedValueEntity(Priority priority) {
this.priority = priority;
}
public Long getId() {
return id;
}
public Priority getPriority() {
return priority;
}
/** Persisted representation is the "code" string, NOT the enum's ordinal or name(). */
public enum Priority {
LOW("L"), MEDIUM("M"), HIGH("H");
@EnumeratedValue
private final String code;
Priority(String code) {
this.code = code;
}
public String getCode() {
return code;
}
}
}