Fixed
Details
Details
Assignee
Unassigned
UnassignedReporter
Dan Plaskon
Dan PlaskonComponents
Fix versions
Affects versions
Priority
Who's Looking?
Open Who's Looking?
Created March 12, 2010 at 8:17 AM
Updated December 6, 2010 at 10:02 AM
Resolved December 6, 2010 at 10:02 AM
When a Size constraint is specified for a collection of children belonging an entity, it is not evaluated upon update if the only changes made to the parent entity is to alter the child collection.
For instance, if you have specified <Size(Min:=1,Message:="Collection must contain at least one entity")> and subsequently remove all children from this collection (making no other changes to the parent entity) - nhibernate will persist the entity (because the PreUpdate listener will not be triggered).
This could likely be solved using CollectionEventHanders to examine the state of the collection before allowing persistence.
I suppose it could also be argued that the NotNull contraint could be considered for the collection as well - but I'm not sure if that makes sense in this context or not.