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:
@@ -0,0 +1,51 @@
|
||||
package com.ankurm.hibernatedemo.immutable;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
/**
|
||||
* A MUTABLE parent entity (no {@code @Immutable} on the class) whose collection is marked
|
||||
* {@code @Immutable}. This isolates the collection-level annotation's own behaviour, per the
|
||||
* article's "Advanced Usage: Immutable Collections" section, from the entity-level one.
|
||||
*/
|
||||
@Entity
|
||||
public class RateWithAuditTrail {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rate_audit_seq")
|
||||
private Long id;
|
||||
|
||||
private String pair;
|
||||
|
||||
@Immutable
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
private List<AuditTrail> auditTrails = new ArrayList<>();
|
||||
|
||||
protected RateWithAuditTrail() {
|
||||
// JPA
|
||||
}
|
||||
|
||||
public RateWithAuditTrail(String pair) {
|
||||
this.pair = pair;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getPair() {
|
||||
return pair;
|
||||
}
|
||||
|
||||
public List<AuditTrail> getAuditTrails() {
|
||||
return auditTrails;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user