E
- the generic type of the referenced entitypublic class SQLEntityRef<E extends SQLEntity> extends BaseEntityRef<Long,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 |
SQLEntityRef(Class<E> type,
BaseEntityRef.OnDelete deleteHandler) |
Modifier and Type | Method and Description |
---|---|
protected Long |
coerceToId(Object id)
Converts the given object into an id.
|
protected Optional<E> |
find(Class<E> type,
Long id)
Performs the lookup of the entity with the given id.
|
static <E extends SQLEntity> |
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 SQLEntityRef(Class<E> type, BaseEntityRef.OnDelete deleteHandler)
public static <E extends SQLEntity> SQLEntityRef<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, Long id)
BaseEntityRef
find
in class BaseEntityRef<Long,E extends SQLEntity>
type
- the type to search forid
- the id to lookupprotected Long coerceToId(Object id)
BaseEntityRef
coerceToId
in class BaseEntityRef<Long,E extends SQLEntity>
id
- the value to coerceCopyright © 2018. All rights reserved.