77 lines
2.1 KiB
Java
Executable File
77 lines
2.1 KiB
Java
Executable File
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;
|
|
}
|
|
}
|