T - source class typeT_ID - T class id typeD - target class typeD_ID - D class id typepublic interface RelationshipRepository<T,T_ID extends Serializable,D,D_ID extends Serializable>
Base unidirectional repository responsible for operations on relations. All of the methods in this interface have fieldName field as last parameter. It solves a problem of many relationships between the same resources.
There are two methods that are used for To-One relationships:
There are two methods that are used for To-One relationships:
The reason why there is more than one method for To-Many relationships manipulation is to prevent race condition situations in which a field could be changed concurrently by another request.
| Modifier and Type | Field and Description |
|---|---|
static int |
TARGET_TYPE_GENERIC_PARAMETER_IDX |
| Modifier and Type | Method and Description |
|---|---|
void |
addRelations(T source,
Iterable<D_ID> targetIds,
String fieldName)
Add a relation to a field.
|
Iterable<D> |
findManyTargets(T_ID sourceId,
String fieldName,
RequestParams requestParams)
Find a relation's target identifiers.
|
D |
findOneTarget(T_ID sourceId,
String fieldName,
RequestParams requestParams)
Find a relation's target identifier.
|
void |
removeRelations(T source,
Iterable<D_ID> targetIds,
String fieldName)
Removes a relationship from a set of relationships.
|
void |
setRelation(T source,
D_ID targetId,
String fieldName)
Set a relation defined by a field.
|
void |
setRelations(T source,
Iterable<D_ID> targetIds,
String fieldName)
Set a relation defined by a field.
|
static final int TARGET_TYPE_GENERIC_PARAMETER_IDX
void setRelation(T source, D_ID targetId, String fieldName)
source - instance of a source classtargetId - id of a target resourcefieldName - name of target's filedvoid setRelations(T source, Iterable<D_ID> targetIds, String fieldName)
source - instance of a source classtargetIds - ids of a target resourcefieldName - name of target's filedvoid addRelations(T source, Iterable<D_ID> targetIds, String fieldName)
source - instance of source classtargetIds - ids of the target resourcefieldName - name of target's fieldvoid removeRelations(T source, Iterable<D_ID> targetIds, String fieldName)
source - instance of source classtargetIds - ids of the target resourcefieldName - name of target's fieldD findOneTarget(T_ID sourceId, String fieldName, RequestParams requestParams)
sourceId - an identifier of a sourcefieldName - name of target's filedrequestParams - parameters sent along with the requestIterable<D> findManyTargets(T_ID sourceId, String fieldName, RequestParams requestParams)
sourceId - an identifier of a sourcefieldName - name of target's filedrequestParams - parameters sent along with the requestCopyright © 2015. All Rights Reserved.