company logo

autodelete - AUTO_DELETE option

The option can be set in order to indicate, that an instance should be deleted, when a collection (relationship) becomes empty. When the option has been defined for more than one relationship, the instance will be deleted automatically, when the first marked collection becomes empty.

The option is not checked, when creating an instance, but only, when removing instances from collections. In order to handle the option properly, relationships requesting autodelete require an inverse relationship. Otherwise, the option will be ignored.

// delete course instances when the last student has left the course

  class course {

     ...

     relationship set<Person> students AUTO_DELETE;

  }

Type: logical