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,87 @@
|
||||
package com.ankurm.hibernatedemo.procedure;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ColumnResult;
|
||||
import jakarta.persistence.ConstructorResult;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.NamedStoredProcedureQueries;
|
||||
import jakarta.persistence.NamedStoredProcedureQuery;
|
||||
import jakarta.persistence.ParameterMode;
|
||||
import jakarta.persistence.SqlResultSetMapping;
|
||||
import jakarta.persistence.SqlResultSetMappings;
|
||||
import jakarta.persistence.StoredProcedureParameter;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* Entity for docs/08-stored-procedures.md (merged posts 4867 + 4881). Backed by HSQLDB 2.7.3
|
||||
* real SQL/PSM stored procedures created in {@code ProcedureSchemaSupport} -- these are not
|
||||
* described in prose, they are compiled and executed.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "PROC_EMPLOYEES")
|
||||
@NamedStoredProcedureQueries({
|
||||
@NamedStoredProcedureQuery(
|
||||
name = "ProcEmployee.getTax",
|
||||
procedureName = "GET_TAX",
|
||||
parameters = {
|
||||
@StoredProcedureParameter(mode = ParameterMode.IN, name = "emp_id", type = Integer.class),
|
||||
@StoredProcedureParameter(mode = ParameterMode.OUT, name = "tax_amount", type = BigDecimal.class)
|
||||
}
|
||||
),
|
||||
@NamedStoredProcedureQuery(
|
||||
name = "ProcEmployee.listAll",
|
||||
procedureName = "LIST_EMPLOYEES",
|
||||
resultClasses = ProcEmployee.class
|
||||
)
|
||||
})
|
||||
@SqlResultSetMappings({
|
||||
@SqlResultSetMapping(
|
||||
name = "EmployeeSummaryMapping",
|
||||
classes = @ConstructorResult(
|
||||
targetClass = EmployeeSummary.class,
|
||||
columns = {
|
||||
@ColumnResult(name = "ID", type = Integer.class),
|
||||
@ColumnResult(name = "NAME", type = String.class)
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
public class ProcEmployee {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(precision = 10, scale = 2)
|
||||
private BigDecimal salary;
|
||||
|
||||
protected ProcEmployee() {
|
||||
// JPA
|
||||
}
|
||||
|
||||
public ProcEmployee(Integer id, String name, BigDecimal salary) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.salary = salary;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public BigDecimal getSalary() {
|
||||
return salary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProcEmployee{id=%s, name=%s, salary=%s}".formatted(id, name, salary);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user