Thank you both for your answers.  Your responses validate what I
thought in the back of my head and what I have already implemented.

todd

On Jan 20, 4:59 am, Stefan Steinegger <[email protected]> wrote:
> I agree with Markus. NH should always persist what you have in memory.
> If you have multiple references in memory and want to remove them all
> at once, you need to do this in the business logic. Then you can
> expect from NH to do the same in the database.
>
> The business logic should always look after itself. It should also
> work if there is NO NHibernate around. So NHibernate is not ALLOWED to
> do anything else than persisting the memory state. This would make the
> business logic dependent to it.
>
> On 20 Jan., 01:12, todd brooks <[email protected]> wrote:
>
> > I have three entities: Customer, Device and LocationTag.
>
> > Customers have a list of LocationTags (nothing more than an ID and a
> > Description). They also have a list of Devices.
>
> > Devices are tagged with a subset of the Customer's LocationTags, so
> > Devices have a List of LocationTags, too (but only of the Customer's).
>
> > If I delete a LocationTag from the Customer's list, I would like it
> > also to cascade delete from the list of LocationTags in the Device.
> > Currently, I have it working but with manual code in the domain object
> > classes, but violates DRY in my opinion.
>
> > Is it possible to accomplish this via NHibernate?
>
> > Better question is whether or not these should even be attempted in
> > NHibernate as opposed to putting that logic in the domain object(s).
>
> > Simplified Fluent NHib mappings:
>
> > Customer
>
> >         public CustomerMap()
> >     {
> >         WithTable("Customers");
>
> >         Id(x => x.ID)
> >             .WithUnsavedValue(0)
> >             .GeneratedBy.Identity();
>
> >         Map(x => x.Name);
>
> >         HasMany<LocationTag>(t => t.LocationTags).IsInverse();
>
> >         HasMany<Device>(d => d.Devices).IsInverse();
> >     }
>
> > Device
>
> >         public DeviceMap()
> >     {
> >         WithTable("Devices");
>
> >         Id(x => x.ID)
> >             .WithUnsavedValue(0)
> >             .GeneratedBy.Identity();
>
> >         Map(x => x.Name);
>
> >         HasMany<LocationTag>(x => x.LocationTags).IsInverse();
> >     }
>
> > LocationTag
>
> >         public LocationTagMap()
> >     {
> >         WithTable("LocationTags");
>
> >         Id(x => x.ID)
> >             .WithUnsavedValue(0)
> >             .GeneratedBy.Identity();
>
> >         Map(x => x.Description);
> >     }
--~--~---------~--~----~------------~-------~--~----~
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