Andrea Boriero (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-16448 (
https://hibernate.atlassian.net/browse/HHH-16448?atlOrigin=eyJpIjoiNjY4Ym...
)
Re: After upgrading to Hibernate 6.2.0.Final, the unique attribute of `@JoinColumn` always
behaves as true. (
https://hibernate.atlassian.net/browse/HHH-16448?atlOrigin=eyJpIjoiNjY4Ym...
)
it’s a OneToOne relationship so it is correct that the join column is unique, 1 Card ↔︎ 1
User, if the same user can have multiple cards than the association should be a ManyToOne
and in that case you will see that the column used as foreign key is not unique.
For
@Entity(name = "MembershipCard")
public static class MembershipCard {
@Id
@Column(name = "card_number")
private String number;
@ManyToOne
@JoinColumn(name = "user_email")
private Student owner;
private boolean enabled;
}
@Entity(name = "Student")
public static class Student {
@Id
private String email;
private String name;
}
Hibernate generates
create table MembershipCard (
card_number varchar(255) not null,
enabled boolean not null,
user_email varchar(255),
primary key (card_number)
)
(
https://hibernate.atlassian.net/browse/HHH-16448#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16448#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#100221- sha1:9ff53d8 )