@UniqueConstraint allows you to name the constraint, while @Column(unique = true) generates a random name (e.g. UK_3u5h7y36qqa13y3mauc5xxayq). That's alright for the annotation itself, but if you implement a NamingStrategy, it should allow us to name the constraints when using @Column(unique = true) also. Otherwise the naming get totally inconsistent. If you search for "UK_" in Hibernate code you find all places where the naming is hardcoded. It should be easy to change this to use a naming strategy. |