|
Preconditions:
Create a parent entity with OneToMany association to its children:
Parent { @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent", fetch = FetchType.EAGER) @Size(min = 0, max = 4) List<Child> children = new ArrayList<Child>();
// invoke inside transaction public void addChild(Child child) { child.setParent(this); children.add(child); }
}
Reproduction steps: Create a parent entity and try to add five children, one at a time.
Result: All five children successfully created w/o throwing validation errors
Expected result: Validation error when adding the 5th child.
Additional notes: org/hibernate/event/internal/DefaultFlushEntityEventListener.java:isUpdateNecessary() method returns false for described above steps, but should return true since collection size is changing and this must be validated.
|