The Fetch Policy can be used to optimize your object graph. Onyx enables developers to load only what they need. There are instances when users would like to reduce the size of the object graph in order to save memory and network overhead by lazily or not loading relationships.
Policy | Description |
---|---|
FetchPolicy.EAGER |
Eager fetch policy will hydrate the entire relationship and all of the subsequent object graph. |
FetchPolicy.LAZY |
Lazy fetch policy will return references to the relationship data. When referenced using the List interface, the relationship will be lazily filled in. |
FetchPolicy.NONE |
The relationship will not be populated upon fetching an entity. It will sometimes be populated in the event the entity is already cached. |
You can download the code for this example here:
OnyxDevTools/onyx-database-samples/relationships.
For this example all of the relationships have CascadePolicy of CascadePolicy.SAVE or CascadePolicy.ALL. This is to ensure the entire object graph is persisted.
Onyx maintains an elastic cache and does not guarantee items in memory. If you need to reference that relationship, you should use manager.initialize(episode, "actors") to hydrate the relationship.
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.