To me this means losing an important data security feature when using JDO over other access paths to the DB. FK constraints can prevent you from inadvertently deleting data, and by silently removing any dangling references on the object level (and so circumventing any FK constraints) you are entirely losing this kind of "safety belt"! JDO would never tell you about these dangling references, but instead would silently go and delete that information.If that's the case, then I wonder why a user would want to have FK constraints in his schema at all? They wouldn't be of much use then.If only using JDO, I agree. What matters is the consistency of the object model, which is managed by the JDO implementation without help from the database. But seldom is JDO the only access path to the database.
If you look at the code in DeleteRequest, you'll see that in execute() it'll null out FKs for any fields obained using getFildsWithRelatedObjects(). The latter's javadoc saysI may also add that, as far as I know, JPOX nulls out only for one-one bidirectional, not for one-many, so there would be some inconsistency of behaviour here.Interesting point, but without another level of detail, it's hard to evaluate this statement.
Craig L Russell schrieb:Why does object model consistency disallow a reference to a deleted object?
2. Deletion of objects when foreign-key is present (JDO-392) (any and all) It seems that there are two different issues: managing the memory model and managing the database. Craig opines that the general case of consistency is already covered in the chapter on mapping, requiring that the object model be consistent after a flush. Object model consistency would disallow a reference to a deleted object, so the natural behavior would be to nullify the reference to the deleted object. For to-many relationships mapped to a foreign key on the other side, the consistency rule would delete the reference from the collection on the one- side of the relationship. So it seems that the JPOX behavior as originally reported is consistent and we might simply document it in the specification.
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!