Can Castor automatically create/remove related objects?
First of all, let’s agree upon terminology. We distinguish dependent and independent objects: -dependent objects are bounded to the parent object’s lifecycle -independent objects have independent lifecycle Thus, dependent objects are created/removed automatically, when their parent object is created/removed, while all operations on independent objects should be performed explicitly. However, with Castor 0.8.x you cannot describe explicitly the kind of object. Instead, the following rule applies: if you have one-to-many relation, and each side of the relation refers to another (Collection attribute on “one” side, simple attribute on “many” side), then “many” side is a dependent object. All other objects are independent. In particular, related objects via one-to-one relation are not created/removed automatically. With Castor 0.9 dependent objects should be described via “depends” attribute of “class” element in mapping configuration file. If you wish some independent object was created a
First of all, let’s agree upon terminology. We distinguish dependent and independent objects: dependent objects are bounded to the parent object’s lifecycle, independent objects have independent lifecycle. Thus, dependent objects are created/removed automatically, when their parent object is created/removed, while all operations on independent objects should be performed explicitly.However, with Castor 0.8.x you cannot describe explicitly the kind of object. Instead, the following rule acts: if you have one-to-many relation, and each side of the relation refers to another (Collection attribute on “one” side, simple attribute on “many” side), then “many” side is a dependent object. All other objects are independent. In particular, related objects via one-to-one relation are not created/removed automatically.With Castor 0.9 dependent objects should be described via “depends” attribute of “class” element in mapping configuration file.