Size constraint is not evaluated when updating an entity

Description

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.

Environment

None

Attachments

1

Activity

Show:

Dan Plaskon 
March 12, 2010 at 11:11 AM

Example of test that needs to pass

Fixed

Details

Assignee

Reporter

Components

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
Who's Looking?

Flag notifications