use of com.blazebit.persistence.FetchBuilder in project blaze-persistence by Blazebit.
the class ManagedViewTypeImpl method renderSecondaryMappings.
@Override
public void renderSecondaryMappings(String viewPath, BaseQueryBuilder<?, ?> baseQueryBuilder, Map<String, Object> optionalParameters, boolean renderFetches) {
if (baseQueryBuilder instanceof CTEBuilder) {
CTEBuilder<?> cteBuilder = (CTEBuilder<?>) baseQueryBuilder;
for (CTEProvider cteProvider : getCteProviders()) {
cteProvider.applyCtes(cteBuilder, optionalParameters);
}
}
for (ViewRoot viewRoot : viewRoots) {
String entityViewRootName = viewRoot.getName();
CorrelationProvider correlationProvider = viewRoot.getCorrelationProviderFactory().create(baseQueryBuilder, optionalParameters);
ExpressionFactory expressionFactory = baseQueryBuilder.getService(ExpressionFactory.class);
Limiter limiter = createLimiter(expressionFactory, viewPath, viewRoot.getLimitExpression(), viewRoot.getOffsetExpression(), viewRoot.getOrderByItems());
String correlationAlias;
if (limiter == null) {
correlationAlias = entityViewRootName;
} else {
correlationAlias = "_sub_" + entityViewRootName;
}
JoinCorrelationBuilder correlationBuilder = new JoinCorrelationBuilder(baseQueryBuilder, optionalParameters, baseQueryBuilder, viewPath, correlationAlias, entityViewRootName, null, viewRoot.getJoinType(), limiter);
correlationProvider.applyCorrelation(correlationBuilder, viewPath);
correlationBuilder.finish();
if (renderFetches && baseQueryBuilder instanceof FetchBuilder<?>) {
((FetchBuilder<?>) baseQueryBuilder).fetch(viewRoot.getFetches());
}
}
}
Aggregations