Supposed I have a User entity and it has a one to many relationship with Post
@OneToMany(
cascade = CascadeType.ALL,
orphanRemoval = true,
fetch = FetchType.LAZY
)
@JoinColumn(
name = "user_id",
foreignKey = @ForeignKey(name = "fk"),
referencedColumnName = "userId")
private List<Post> post = new ArrayList<>();
and this is my Post
entity
@NotBlank(message = "test")
@Column(length = 50)
private String title;
@Column
private String post;
How can I validate the Post when Im inserting a new user? For example this what I passed on the request
{
"name": "Test name",
"username": "Test username",
"post": [
{
"title": "asdasd",
"post": "asdasd"
}
]
}
If I pass a blank string on title
"title": "",
Im getting an error
Validation failed for classes .... during persist time for groups