Database Reference
In-Depth Information
new or changed from the perspective of the node that's being saved, including relation-
ships. John has a new age and name and a new friend. Thus, SDN saves the full object
graph of modified data, bringing Susan along for the ride as well. Remember relationship
properties defined with read-only semantics (that is, those of the Iterable collection
type) won't be persisted.
Eager versus lazy loading
SusangetssavedbydefaultwhenJohnissaved,butisshealsoloadedwhenJohnisloaded?
The official answer is “It depends.” If the SDN default configuration is in play, as in this
case,theanswerisinitially“No.”Thisisbecause,bydefault,SDNdoesn'tengageineager
relationship instantiation when loading a domain entity's relationship-based properties.
Eager loading would involve SDN actively following any relationships that may exist on
an entity and then also loading these entities, including all of their properties as well as
their relationships. To conserve memory and prevent potentially loading vast swathes of
the graph into memory when it's not explicitly needed, SDN defaults to lazy loading.
So what happens if you ask for entities that have been lazily loaded? Take a look at the
following listing.
Listing 9.11. Implications for lazy loading
For each node entity to be lazily loaded, SDN still instantiates a node entity POJO for the
underlying entity, but it will only populate the property annotated with @GraphId . The
 
Search WWH ::




Custom Search