I'll go for implementing the business rules one by one. At least I have perfect control then, and any other developer taking over the project knows what's going on when deleting something.
On Fri, Feb 6, 2009 at 12:29 PM, Germán Schuager <[email protected]>wrote: > I would try something like this: > > open session > delete entity > commit transaction > if no exception then > set entity.deleted = true > persist entity back to db > return true > else > return false (entity could not be deleted) > > I don't know if this works, but it seems that you can take advantage of the > foreing key checks from the DB and if it allows you to delete your entity, > then you re-add it with the Deleted property set to true. > > Just an idea. > > > On Thu, Feb 5, 2009 at 1:41 PM, Bart Reyserhove <[email protected] > > wrote: > >> That's the part we already have. I'm trying to find a elegant solution to >> check whether I can soft delete something. E.g.: it is not allowed to delete >> a company when there are employees linked to that company. This is of course >> a trivial example and you can imagine that there is a lot linked to a >> company in the domain model. >> I want to avoid that if tomorrow a developer creates some entity and >> associates that with a company that the delete business rule that checks >> whether a company can be deleted needs to be changed. One day or another >> someone forgets and you what happens next... >> >> >> On Thu, Feb 5, 2009 at 5:27 PM, Will Shaver <[email protected]>wrote: >> >>> Look in NHibernate Contrib >>> \trunk\src\NHibernate.Burrow\src\NHibernate.Burrow.AppBlock\SoftDelete >>> >>> You can set up cascades for all of your objects, and then set a delete >>> flag in an interceptor or event handler. >>> >>> >>> On Thu, Feb 5, 2009 at 8:24 AM, Robin Nadeau <[email protected]> wrote: >>> >>>> What about creating your own session object, that overloads the delete >>>> to setting a deleted property to true? >>>> >>>> But I agree, this feature would be really nice. >>>> >>>> On Thu, Feb 5, 2009 at 11:21 AM, Bart Reyserhove < >>>> [email protected]> wrote: >>>> >>>>> Hi group, >>>>> In our application most of the entities are not really deleted. We put >>>>> a deleted property on "true". >>>>> Before deleting something checks need to happen to verify whether it is >>>>> allowed to delete the entity. This can become a complex thing when >>>>> entities >>>>> are referenced a lot from other places in the domain model. It is also >>>>> pretty dangerous because if you forget something in the check there will >>>>> be >>>>> no delete database constraint kicking in because nothing is really >>>>> deleted. >>>>> >>>>> It would be really cool if this could be solved in some generic way >>>>> based on the information NHibernate has on the associations. Does anyone >>>>> have an idea whether this can be done and how I would best approach this? >>>>> >>>>> Thanks, >>>>> >>>>> Bart >>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> Robin Nadeau, B.Eng. >>>> Software Developer >>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
