I can think of several ways of doing that, usually with the interceptor
checking the existing properties.
The problem is that none of them are full proof.

For example, if I don't have 2 way association between things.
Then you need to traverse the entire model to find the relevant things.

It is not hard, and can be cached, the problem is that I would much rather
have a bug in my code than introduce this complexity into the code base.
Bugs can be fixed, but it is hard to reduce complexity.

On Thu, Feb 5, 2009 at 6: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
-~----------~----~----~----~------~----~------~--~---

Reply via email to