mklinkj (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzEzOWU2YTk3...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16448?atlOrigin=eyJpIjoiNzEzOW...
) HHH-16448 (
https://hibernate.atlassian.net/browse/HHH-16448?atlOrigin=eyJpIjoiNzEzOW...
) 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=eyJpIjoiNzEzOW...
)
Issue Type: Bug Affects Versions: 6.2.0 Assignee: Unassigned Attachments:
HibernateUpgradeJoinColumnTest.zip Components: hibernate-core Created: 07/Apr/2023 15:35
PM Environment: * HSQLDB 2.7.1
* Hibernate 6.2.0.Final Priority: Major Reporter: mklinkj (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Hello.
There was no problem when using Hibernate 6.1.7.Final version, but after upgrading to
Hibernate 6.2.0.Final, the unique property of @JoinColumn always operates as true.
For example, two entities are:
* MemberShipCard Entity
@Entity
public class MembershipCard {
@Id
@Column(name = "card_number" )
private String number;
@OneToOne
@JoinColumn(name = "user_email" )
private Student owner;
private LocalDateTime expiryDate;
private boolean enabled;
}
* Student Entity
@Entity
@EqualsAndHashCode(onlyExplicitlyIncluded = true )
public class Student {
(a)EqualsAndHashCode.Include @Id private String email;
private String name;
private LocalDateTime createDate;
}
Table creation SQL for MemberShipCard entity in Hibernate 6.1.7.Final
---------------------------------------------------------------------
create table membership_card (
card_number varchar (255) not null ,
enabled boolean not null ,
expiry_date timestamp (6),
user_email varchar (255),
primary key (card_number)
)
Table creation SQL for MemberShipCard entity in Hibernate 6.1.7.Final
---------------------------------------------------------------------
create table membership_card (
enabled boolean not null ,
expiry_date timestamp (6),
card_number varchar (255) not null ,
user_email varchar (255) unique , /* < -- Setting UNIUQE */
primary key (card_number)
)
Please inquire if there is any problem with the above operation.
* Example Project
*
https://github.com/mklinkj/QnA/tree/master/JPA/HibernateUpgradeJoinColumn...
* An example has been created in HSQLDB memory mode so you can check it right away
(
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:916089c )