Given:
{code:java} @Entity public static class B { @Id @Column(length = 12) String code;
@Id @Column(precision = 10, scale = 0) BigDecimal cost;
@Id @Enumerated(EnumType.STRING) Enum type;
@Id long id; }
@Entity (name = "A") public static class A { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private int id;
@ManyToOne(cascade = CascadeType.PERSIST) B b; }{code}
The generated DDL is:
{code:sql}create table "EnumTest$B" ( type varchar(255) not null check (type in ('A','B')), id bigint not null, cost numeric(10,0) not null, code varchar(12) not null, primary key (code, cost, id, type) )
create table A ( id integer generated by default as identity, "b_code" varchar(255), "b_cost" bigint, "b_id" numeric(38,2), "b_type" varchar(12), primary key (id) )
alter table if exists A add constraint FK60kjd2qxbg6infjjee27fhvjp foreign key ("b_type", "b_id", "b_cost", "b_code") references "EnumTest$B"{code}
which is very wrong in multiple ways! |
|