Tôi có một thực thể Person với một tài sản thu Email:Làm cách nào để thực thi ràng buộc xác thực trên thuộc tính của thực thể có thể nhúng?
@ElementCollection
@CollectionTable(schema="u",name="emails",[email protected](name="person_fk"))
@AttributeOverrides({
@AttributeOverride(name="email",[email protected](name="email",nullable=false)),
})
public List<EmailU> getEmails() {
return emails;
}
Trong lớp Email của tôi, tôi đã cố gắng để chú thích email với @Email:
@Embeddable
public class EmailU implements Serializable {
private String email;
public EmailU(){
}
@Email
public String getEmail() {
return email;
}
}
Nhưng nó không hoạt động. Cách tiếp cận của tôi ở đây là gì?