load<T extends Entity> function
Loads the data of the given OID from the storage into the given entity.
Note: it will invoke access[oid]
first to see if there is a cached version.
If so, return it directly.
newInstance
- the method to instantiate the entity for holding the data loaded from database. You usually instantiate it with thebe
constructor (see Entity.be).fields
- a collection of fields to load. Note: if you'd like to load an expression (aka., virutal column, or calculated column), you can pass(SQL expression) name
. For example:(due is not null and who is not null) active
.option
- an option for loading the entity. Technically, you can pass anything that your access provider supports. For SQL, itt could benull
, forShare and forUpdate. Default: null (means no lock at all).
It throws EntityNotFoundException if the entity is not found (including oid is null).
Implementation
Future<T> load<T extends Entity>(Access access, String oid,
T newInstance(String oid), [Iterable<String>? fields,
AccessOption? option]) async {
final entity = await loadIfAny(access, oid, newInstance, fields, option);
if (entity == null)
throw EntityNotFoundException(oid);
return entity;
}