Reference factory

If aggregate persistence support is enabled, the SDK provides a Factory for root entity references. The factory offers methods to create new references to root entities, grouped by the namespaces in which the entities are defined.

If a root entity referenced is modelled as a property in another entity the return value of the factory call can be directly used there. The response also allows to access the id of the root entity and load the root entity.

// Create an entity reference for root entity using reference factory
const ref = this.factory.reference.nsacrnm.RootEntityIdentifier(someEntityId);

// use root entity reference as property in another entity
entity1.someRootEntityReference = ref;

// read the id of the root entity
const id = ref.refId;

// load referenced entity from database
const rootEntityInstance = await ref.load();