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 {code:java}@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; }{code} * Student Entity {code:java}@Entity @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class Student { @EqualsAndHashCode.Include @Id private String email; private String name; private LocalDateTime createDate; }{code}
h3. Table creation SQL for MemberShipCard entity in Hibernate 6.1.7.Final
{code:sql} 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) ){code}
h3. Table creation SQL for MemberShipCard entity in Hibernate 6. 1 2 . 7 0 .Final
{code:sql} 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) ){code}
Please inquire if there is any problem with the above operation.
* Example Project ** [https://github.com/mklinkj/QnA/tree/master/JPA/HibernateUpgradeJoinColumnTest|https://github.com/mklinkj/QnA/tree/master/JPA/HibernateUpgradeJoinColumnTest|smart-link] ** An example has been created in HSQLDB memory mode so you can check it right away |
|