Fabio,

I've added a patch that demonstrates the test that needs to pass -
hopefully I did this correctly :)

On Mar 12, 1:32 pm, Fabio Maulo <[email protected]> wrote:
> Thanks
>
> 2010/3/12 DanPlaskon <[email protected]>
>
>
>
>
>
> > Fabio,
>
> > I believe the example I posted was meant for database deployments
> > where database-level cascade deletes aren't an option - I was already
> > aware of the "on-cascade='delete'" option for the inverse side of sets
> > when it is.
>
> > I've opened an initial ticket in JIRA - I'll see what I can do about
> > putting together some example code in the next few days (currently
> > swamped here at work).
>
> > Cheers,
>
> > -Dan
>
> > On Mar 12, 11:39 am, Fabio Maulo <[email protected]> wrote:
> > > well... what can I say ?....
> > > If you are a ConfORM user you will see which is the mapping pattern for a
> > > bidirectional-one-to-many with *one-shot-delete* :
> > > public class Item
> > > {
> > > private ISet<Bid> _bids;
> > > public long Id { get; private set; }
> > > public ISet<Bid> Bids
> > > {
> > > get { return _bids; }
>
> > > }
> > > }
>
> > > public class Bid
> > > {
> > > public long Id { get; private set; }
> > > public Item Item { get; set; }
> > > public Double Amount { get; private set; }
> > > public string Code { get; private set; }
>
> > > }
>
> > > The whole mapping in ConfORM is :
> > > public void MapDomain(ObjectRelationalMapper orm)
> > > {
> > > orm.TablePerClass(new[] { typeof(Item), typeof(Bid) });
> > > orm.Patterns.PoidStrategies.Add(new NativePoidPattern());
>
> > > }
>
> > > *Yes! only two lines!*
>
> > > And the result XML is (for those about to rock) :
> > >   <class name="Item">
> > >     <id name="Id" type="Int64">
> > >       <generator class="native" />
> > >     </id>
> > >     <set name="Bids" access="nosetter.camelcase-underscore"
> > inverse="true"
> > > cascade="all,delete-orphan">
> > >       <key column="Item" on-delete="cascade" />
> > >       <one-to-many class="Bid" />
> > >     </set>
> > >   </class>
> > >   <class name="Bid">
> > >     <id name="Id" type="Int64">
> > >       <generator class="native" />
> > >     </id>
> > >     <many-to-one name="Item" />
> > >     <property name="Amount" />
> > >     <property name="Code" />
> > >   </class>
>
> > > As you can see ConfORM knows how map the *one-shot-delete* :
> > >     <set name="Bids" access="nosetter.camelcase-underscore"
> > inverse="true"
> > > cascade="all,delete-orphan">
> > >       <key column="Item" on-delete="cascade" />
> > >       <one-to-many class="Bid" />
> > >     </set>
>
> > > btw... backing to our concern if you have time to create a test to pass
> > and
> > > a JIRA ticket we can study a solution.
>
> > > 2010/3/12 DanPlaskon <[email protected]>
>
> > > > Fabio,
>
> > > > Alright - I see what you're getting at...something like this:
>
> > > >http://elegantcode.com/2009/07/19/nhibernate-2-1-and-collection-event.
> > ..
> > > > (but obviously handing validation events)
>
> > > > Also...wouldn't we be interested in
>
> > > > IPreCollectionUpdateEventListener
> > > > IPreCollectionRemoveEventListener
>
> > > > Instead of the "Post" ones?
>
> > > > I imagine these would need to examine only "Size" and "NotNull"
> > > > validation attributes on collections, to ensure that the contraints
> > > > specified were satisfied.
>
> > > > Is this along the lines of what you were thinking?
>
> > > > On Mar 12, 10:55 am, Fabio Maulo <[email protected]> wrote:
> > > > > More than a workaroud we should think about a solution
> > > > > IPostCollectionUpdateEventListener
> > > > > IPostCollectionRemoveEventListener
>
> > > > > Can you study it a little bit and send me a proposal ?
>
> > > > > If you have time obviously.
>
> > > > > btw a JIRA ticket is welcomehttp://216.121.112.228/browse/NHV
>
> > > > > 2010/3/12 DanPlaskon <[email protected]>
>
> > > > > > Hello,
>
> > > > > > I have a "Size" validation constraint specified for a collection on
> > an
> > > > > > entity of mine (Min is set to 1, to specify that the entity must
> > have
> > > > > > at least one child entity in its collection).
>
> > > > > > This works as expected for the initial creation, however validation
> > > > > > does not occur upon update of the entity if the only change made to
> > it
> > > > > > is to remove all child entities from the collection. I imagine this
> > > > > > occurs because the entity itself is not considered dirty (since the
> > > > > > only changes made were to its collection of child entities), and
> > thus
> > > > > > the ValidatePreUpdateEventListener does not evaluate it at all.
> > > > > > However, this poses a problem, because the entity has technically
> > > > > > entered an invalid state (its collection does not contain any child
> > > > > > entities) and NHibernate is all to happy to remove all child
> > entities
> > > > > > without checking the validity of the parent.
>
> > > > > > So...that being said...what's the workaround for this? If further
> > > > > > details are required, please don't hesitate to ask :)
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "nhusers" group.
> > > > > > To post to this group, send email to [email protected].
> > > > > > To unsubscribe from this group, send email to
> > > > > > [email protected]<nhusers%[email protected]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > ­>
> > > > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > <nhusers%252bunsubscr...@googlegroup­s.com>
> > > > ­>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > > > --
> > > > > Fabio Maulo- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nhusers" group.
> > > > To post to this group, send email to [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<nhusers%[email protected]­>
> > <nhusers%[email protected]<nhusers%252bunsubscr...@googlegroup­s.com>
> > ­>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/nhusers?hl=en.
>
> > > --
> > > Fabio Maulo- Hide quoted text -
>
> > > - Show quoted text -
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nhusers" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<nhusers%[email protected]­>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/nhusers?hl=en.
>
> --
> Fabio Maulo- Hide quoted text -
>
> - Show quoted text -

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to