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,76 @@
|
||||
package com.ankurm.hibernatedemo.testdb;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
|
||||
/**
|
||||
* Backs docs/09-testing-in-memory-databases.md (post 4868 rewrite). One entity, run through the SAME mapping
|
||||
* against H2 2.4.240, HSQLDB 2.7.3 and Apache Derby 10.16.1.1 via {@link TestDbBootstrap} --
|
||||
* the DDL differences, dialect selection, and cross-database failure case are all read off
|
||||
* this exact class.
|
||||
*
|
||||
* <ul>
|
||||
* <li>{@code id} -- {@code GenerationType.AUTO}, deliberately not IDENTITY or SEQUENCE, to
|
||||
* see what each dialect resolves AUTO to.</li>
|
||||
* <li>{@code sku} -- {@code varchar(5)}, short enough that an over-length value is a real
|
||||
* constraint violation on at least one of the three databases.</li>
|
||||
* <li>{@code order} -- a column named after a SQL reserved word on purpose (see
|
||||
* {@code @Column(name = "\"order\"")}), the classic "works on some databases, breaks on
|
||||
* others" trap.</li>
|
||||
* <li>{@code active} -- a plain {@code boolean}, to see how each dialect maps and prints it.</li>
|
||||
* <li>{@code description} -- {@code @Lob}, to see clob/text mapping differences.</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Entity
|
||||
public class TestDbWidget {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column(length = 5)
|
||||
private String sku;
|
||||
|
||||
@Column(name = "\"order\"")
|
||||
private Integer order;
|
||||
|
||||
private boolean active;
|
||||
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
protected TestDbWidget() {
|
||||
// JPA
|
||||
}
|
||||
|
||||
public TestDbWidget(String sku, Integer order, boolean active, String description) {
|
||||
this.sku = sku;
|
||||
this.order = order;
|
||||
this.active = active;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
public Integer getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user