When using a custom ImplicitNamingStrategy#determineUniqueKeyName, the following mapping only partially applies the intended naming scheme:
@Entity
@Table(
uniqueConstraints = { @UniqueConstraint(columnNames = { "ukColumn1", "ukColumn2" }) }
)
class Parent {
@Id
Long id;
String ukColumn1;
String ukColumn2;
@Column(unique = true)
String ukAnnotatedColumn;
@OneToOne
Child child;
}
The unique key applied via @UniqueConstraint correctly uses ImplicitNamingStrategy#determineUniqueKeyName. The two unique columns ukAnnotatedColumn (via @Column(unique = true)) and child (via @OneToOne) still use a hashed key name and ignore the ImplicitNamingStrategy. All unique key names should be consistently generated via ImplicitNamingStrategy#determineUniqueKeyName. Afaict, the unique keys for single unique columns get generated in a different phase from the @UniqueConstraints. When I tried to create a test case for this bug, only the @UniqueConstraint was available via org.hibernate.mapping.Table.getUniqueKeys(). So I don’t know how to create a test case for this issue. |