@Override
public Object getRelation(DataStoreTransaction relationTx,
Object entity,
String relationName,
Optional<FilterExpression> filter,
Optional<Sorting> sorting,
Optional<Pagination> pagination,
RequestScope scope) {
relationTx = getRelationTransaction(entity, relationName);
DataStoreTransaction entityTransaction = getTransaction(entity.getClass());
EntityDictionary dictionary = scope.getDictionary();
Class<?> relationClass = dictionary.getParameterizedType(entity, relationName);
String idFieldName = dictionary.getIdFieldName(relationClass);
if (entityTransaction != relationTx && relationTx instanceof BridgeableTransaction) {
BridgeableTransaction bridgeableTx = (BridgeableTransaction) relationTx;
RelationshipType relationType = dictionary.getRelationshipType(entity.getClass(), relationName);
Serializable id = filter.map(fe -> extractId(fe, idFieldName, relationClass)).orElse(null);
if (relationType.isToMany()) {
return id == null ? bridgeableTx.bridgeableLoadObjects(
this, entity, relationName, filter, sorting, pagination, scope)
: bridgeableTx.bridgeableLoadObject(this, entity, relationName, id, filter, scope);
}
return bridgeableTx.bridgeableLoadObject(this, entity, relationName, id, filter, scope);
}
return entityTransaction.getRelation(relationTx, entity, relationName, filter, sorting, pagination, scope);
}