Unless you apply database foreign key constraints extensively, it is possible to end up with orphaned keys in your database. For example, suppose Person p has a reference to Address a. If you delete a without nulling p's reference, p's database record will wind up with an orphaned key to the non-existant a record.
![]() | Note |
---|---|
One way of avoiding orphaned keys is to use dependent fields. See Section 6.2.1.3, “dependent”. |
Kodo's kodo.OrphanedKeyAction configuration property controls what action to take when Kodo encounters an orphaned key. You can set this plugin string (see Section 2.4, “Plugin Configuration”) to a custom implementation of the kodo.event.OrphanedKeyAction interface, or use one of the built-in options:
log: Log a message for each orphaned key. This is an alias for the kodo.event.LogOrphanedKeyAction class. This setting has the following additional properties:
Channel: The channel to log to. Defaults to kodo.Runtime.
Level: The level to log at. Defaults to WARN.
exception: Throw a javax.jdo.JDOObjectNotFoundException when Kodo discvers an orphaned key. This is an alias for the kodo.event.ExceptionOrphanedKeyAction class.
none: Ignore orphaned keys. This is an alias for the kodo.event.NoOrphanedKeyAction class.