Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTcwMzIyYmE2...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16514?atlOrigin=eyJpIjoiYTcwMz...
) HHH-16514 (
https://hibernate.atlassian.net/browse/HHH-16514?atlOrigin=eyJpIjoiYTcwMz...
) bad bug resulting from column sorting (
https://hibernate.atlassian.net/browse/HHH-16514?atlOrigin=eyJpIjoiYTcwMz...
)
Issue Type: Bug Affects Versions: 6.2.1 Assignee: Unassigned Components: hibernate-core
Created: 25/Apr/2023 07:03 AM Priority: Critical Reporter: Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Given:
@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;
}
The generated DDL is:
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"
which is very wrong in multiple ways!
(
https://hibernate.atlassian.net/browse/HHH-16514#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16514#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100223- sha1:cdc0af3 )