|
Hi Craig, Craig L Russell schrieb: Hi Jörg,Yes exactly, I find it good if the application programmer must explicitly nullify any references before deleting. That way he'll know what relationships exactly he is going to remove the object from. If it happens transparently and without notice, he might not realize the consequences. I find it adequate that code for deleting objects must be written with care. So in my opinion, and from my experience, FK constraints help to prevent programming mistakes from creating serious data loss. That's interesting, but I wasn't thinking about FKs with an additional NOT-NULL constraint here. I was thinking of simply not allowing the deletion to happen at all, as it turned out to our own surprise, please see below. What I meant to say is that the "delete user" functionality of the application turned out to not having been thought out well enough. It was only when an end-user clicked the "delete"-button on another user that had already created or modified other objects, that we realized we don't want to allow a deletion in this case at all. And we realized it only because luckily an SQLException was thrown due to the constraint violation. In this case, it would have been a serious mistake if the programmer had nullified the relationships explicitly, but in doing so he is forced to think twice about it, hopefully, and you can't prevent people from creating damage on purpose ;) What I was thinking of would in this example be a deletion of a Department that has Employees. I had understood you that you want to transparently have the Employees be removed from the Department when it is deleted. Currently JPOX doesn't do that, and an FK violation occurs. Let's take this a step further. Let's assume that Department has an "employees" Collection field annotated with "mapped-by". That means we have two Java object references that are represented by one FK on the database level. From an object-oriented perspective, I shouldn't need to know that there is only a single FK, and where it is exactly. However, I can delete an Employee without further action, while I cannot delete a Department without further action. There is an asymmetry here that is rooted in the relational nature of the database, and, for the sake of transparency, it should be hidden. For the sake of data security, I'd prefer to hide the asymmetry by throwing exceptions in both cases So I'd even say that it should not be possible to delete an Employee before removing it from its Department's employees collection, because there won't be any FK violation notifying of the dangling object reference. However, if you find that a little over the top, I won't insist too long as our code generator already causes exceptions to be thrown in these cases...
|
- Minutes: JDO TCK Conference Call Friday, June 23 9 am ... Craig L Russell
- Re: Minutes: JDO TCK Conference Call Friday, June 23 9... Erik Bengtson
- JDO TCK Conference Call Friday, June 30 9 am PST Michelle Caisse
- Minutes: JDO TCK Conference Call Friday, June 30 9 am ... Michelle Caisse
- JDO TCK Conference Call Friday, July 14 9 am PST Michelle Caisse
- Minutes: JDO TCK Conference Call Friday, July 14 9 am ... Craig L Russell
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Jörg von Frantzius
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Craig L Russell
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Jörg von Frantzius
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Craig L Russell
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Jörg von Frantzius
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Michael Watzek
- Re: Minutes: JDO TCK Conference Call Friday, July 14 9... Bin Sun
- JDO TCK Conference Call Friday, July 21 9 am PST Michelle Caisse
- Re: JDO TCK Conference Call Friday, July 21 9 am PST Craig L Russell
- JDO TCK Conference Call Friday, July 28 9 am PST Michelle Caisse
- Minutes: JDO TCK Conference Call Friday, July 28 9 am ... Michelle Caisse
- JDO TCK Conference Call Friday, August 4, 9 am PST Michelle Caisse
- Minutes: JDO TCK Conference Call Friday, August 4, 9 a... Craig L Russell
- JDO TCK Conference Call Friday, August 11, 9 am PST Michelle Caisse
- Minutes: JDO TCK Conference Call Friday, August 11, 9 ... Craig L Russell
