Files
hibernate-demo/inheritance/output/01-ddl-single-table.txt
T
asmhatre 807f681ed1 Add inheritance module: SINGLE_TABLE vs JOINED vs TABLE_PER_CLASS on Hibernate 7.4.13.Final
Same payment hierarchy mapped three ways plus @MappedSuperclass, run with plain Hibernate on H2.
Tests assert and write the generated DDL, the INSERT/SELECT SQL, row/insert/FK/nullability counts and
the three failures (NOT NULL on a SINGLE_TABLE subclass column, IDENTITY with TABLE_PER_CLASS, querying a
@MappedSuperclass); Bench writes indicative polymorphic-query timings. No docs folder: depth lives in the post.
2026-10-24 10:02:28 +00:00

34 lines
1.1 KiB
Plaintext

-- DDL generated by Hibernate 7.4.13.Final for H2, strategy SINGLE_TABLE
-- tables created: 2
create sequence st_order_seq start with 1 increment by 50;
create sequence st_payment_seq start with 1 increment by 50;
create table st_order (
id bigint not null,
payment_id bigint not null,
reference varchar(20) not null,
primary key (id)
);
create table st_payment (
amount numeric(12,2) not null,
card_last4 varchar(4),
currency varchar(3) not null,
id bigint not null,
bank_code varchar(11),
payment_type varchar(12) not null check ((payment_type in ('CARD','BANK','WALLET'))),
network varchar(16),
provider varchar(24),
iban varchar(34),
primary key (id),
constraint st_payment_subclass_columns check ((payment_type <> 'CARD' or card_last4 is not null) and (payment_type <> 'BANK' or iban is not null) and (payment_type <> 'WALLET' or provider is not null))
);
alter table if exists st_order
add constraint FKdi3y406uyk3cm6po29lmjirt5
foreign key (payment_id)
references st_payment;