In a word - yes, this is possible. Uniqueness means the column can't have two equal values. null
s in SQL are not values - they are the lack thereof. Since they are not values, they don't affect the uniqueness, and a unique column can have as many null
s as you like.
In JPA, you can specify this with the unique
attribute of the @Column
annotation:
@Column(unique=true)
String email;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…