Search in sources :

Example 1 with MultisetCorrelationBuilder

use of com.blazebit.persistence.view.impl.objectbuilder.transformer.correlation.MultisetCorrelationBuilder in project blaze-persistence by Blazebit.

the class CorrelationMultisetTupleElementMapper method applyMapping.

@Override
public void applyMapping(SelectBuilder<?> queryBuilder, ParameterHolder<?> parameterHolder, Map<String, Object> optionalParameters, ViewJpqlMacro viewJpqlMacro, EmbeddingViewJpqlMacro embeddingViewJpqlMacro, boolean asString) {
    String oldEmbeddingViewPath = embeddingViewJpqlMacro.getEmbeddingViewPath();
    embeddingViewJpqlMacro.setEmbeddingViewPath(embeddingViewPath);
    SubqueryInitiator<?> subqueryInitiator = queryBuilder.selectSubquery("subquery", "TO_MULTISET(subquery)");
    CorrelationProvider correlationProvider = correlationProviderFactory.create(parameterHolder, optionalParameters);
    MultisetCorrelationBuilder correlationBuilder = new MultisetCorrelationBuilder(subqueryInitiator, (ServiceProvider) queryBuilder, correlationAlias);
    correlationProvider.applyCorrelation(correlationBuilder, correlationBasis);
    SubqueryBuilder<?> subqueryBuilder = correlationBuilder.getSubqueryBuilder();
    for (TupleElementMapper mapper : subviewTemplate.getMappers()) {
        mapper.applyMapping(subqueryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro, true);
    }
    if (indexTemplate != null) {
        for (TupleElementMapper mapper : indexTemplate.getMappers()) {
            mapper.applyMapping(subqueryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro, true);
        }
    } else if (indexExpression != null) {
        subqueryBuilder.select(indexExpression);
    }
    if (limiter != null) {
        limiter.apply(parameterHolder, optionalParameters, subqueryBuilder);
    }
    subqueryBuilder.end();
    embeddingViewJpqlMacro.setEmbeddingViewPath(oldEmbeddingViewPath);
}
Also used : MultisetCorrelationBuilder(com.blazebit.persistence.view.impl.objectbuilder.transformer.correlation.MultisetCorrelationBuilder) CorrelationProvider(com.blazebit.persistence.view.CorrelationProvider)

Aggregations

CorrelationProvider (com.blazebit.persistence.view.CorrelationProvider)1 MultisetCorrelationBuilder (com.blazebit.persistence.view.impl.objectbuilder.transformer.correlation.MultisetCorrelationBuilder)1