E
- the generic type of the referenced entitypublic class MongoRef<E extends MongoEntity> extends BaseEntityRef<String,E>
Instead of directly keeping the entity in a Java field, it is wrapped in an EntityRef. This leads to clean semantics for lazy loading as both the ID and (if fetched) the value are stored in this wrapper.
BaseEntityRef.OnDelete
deleteHandler, id, type, value
Modifier | Constructor and Description |
---|---|
protected |
MongoRef(Class<E> type,
BaseEntityRef.OnDelete deleteHandler) |
Modifier and Type | Method and Description |
---|---|
protected String |
coerceToId(Object id)
Converts the given object into an id.
|
protected Optional<E> |
find(Class<E> type,
String id)
Performs the lookup of the entity with the given id.
|
static <E extends MongoEntity> |
on(Class<E> type,
BaseEntityRef.OnDelete deleteHandler)
Generates an entity reference to the given entity type.
|
containsNonpersistentValue, getDeleteHandler, getId, getType, getUniqueObjectName, getValue, is, isEmpty, isFilled, isValueLoaded, setId, setValue
protected MongoRef(Class<E> type, BaseEntityRef.OnDelete deleteHandler)
public static <E extends MongoEntity> MongoRef<E> on(Class<E> type, BaseEntityRef.OnDelete deleteHandler)
E
- the generic type of the referenced entitytype
- the target type to referencedeleteHandler
- determines what happens if the referenced entity is deletedprotected Optional<E> find(Class<E> type, String id)
BaseEntityRef
find
in class BaseEntityRef<String,E extends MongoEntity>
type
- the type to search forid
- the id to lookupprotected String coerceToId(Object id)
BaseEntityRef
coerceToId
in class BaseEntityRef<String,E extends MongoEntity>
id
- the value to coerceCopyright © 2018. All rights reserved.