Hibernate 5.1.0 does not validate entity after changing @OneToMany collection

Description

Preconditions:
Create a parent entity with OneToMany collection:
@Entity
@Table(name = "person")
public class Person {

public Person(String name) {
this.name = name;
}

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;

private String name;

@NotEmpty
@OneToMany(mappedBy = "person", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Cat> cats = new ArrayList<Cat>();

public void setCats(List<Cat> cats) {
this.cats.clear();
this.cats.addAll(cats);
}
}
Reproduction steps:
Create a parent entity with not empty child collection and save it. Then change collection to invalid state (make it empty) and try to save again.
Result:
Entity is successfully saved.
Expected result:
Constraint validation exception
Additional info (SSCCE):
Please find single test reproducing this bug in my github repository by link below:
https://github.com/ZdesMisha/hib-bug-example

Environment

hibernate-core 5.1.0.Final
hibernate-jpa-2.0-api 1.0.1
hibernate-entitymanager 5.1.0
hibernate-validator 5.2.4

Assignee

Unassigned

Reporter

Misha Kharkov

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.1.0

Affects versions

Priority

Major
Configure