Cascading is used to customize how your ORM interacts based on the needs of your business requirements. Onyx supplies several options on how to cascade your data. Here are a few examples.
Policy | Description |
---|---|
CascadePolicy.SAVE |
Persist relationship entity upon invoking a save. This will leave the related entity alone when deleting. It will however remove the relationship reference without persisting the related entity. |
CascadePolicy.DELETE |
When deleting an entity, the related entities will be deleted. The expected response may be different when working to a To Many relationship rather than a To One. When removing an entity from a relationship list, the cascade will not occur. Cascade Delete will only occur when deleting an entity. |
CascadePolicy.ALL |
Includes both CascadePolicy.SAVE and CascadePolicy.DELETE policies. |
CascadePolicy.DEFER_SAVE |
There may be times when batch insertion of entities is required. The Defer Save Cascade Policy can help improve the performance of batch persistence. This will tell the Persistence Manager to ignore related entities and their relationship references upon saving. You can later invoke the PersistenceManager.saveRelationshipsForEntity method to perform the relationship association. |
CascadePolicy.NONE |
When persisting entities, the relationships are ignored. |
In this tutorial you will learn how to defer the cascading of relationship data. This is not a typical workflow but, it will showcase the flexibility of the cascade policy.
There are more examples that illustrate how the Cascade Policy impacts the data model and persistence:
OnyxDevTools/onyx-database-samples/relationships.
Our goal is to bring about change by enabling people to use simple and quality software in order to make sad engineers happy.
Copyright ©2017 Onyx Development Tools, LLC. All rights reserved.