Often this question is asked that what is the difference between isNew() and toBeAdded() methods of the Mbo. Before I explain the difference let me tell you what these methods are –
- isNew() – Returns whether the mbo is new or not. true, if the mbo is new (i.e. created by calling add() or insert() methods), otherwise false.
- toBeAdded() – Returns whether the Mbo is to be added to storage
- toBeDeleted() – Returns whether the Mbo is to be deleted from storage
- toBeSaved() – Returns whether the object need to be saved to persistent storage. This will also check child objects.
All these method are in the psdi.mbo.Mbo class and have a return type as Boolean.
The difference is explained using the scenarios in the below table
|New Mbo Added||True||True||False||True|
|New Mbo Added, deleted before saving the Mbo||True||False||True||False|
|Existing Mbo updated||False||False||False||True|
|Existing Mbo deleted||False||False||True||False|