Search in sources :

Example 6 with FullQueryBuilder

use of com.blazebit.persistence.FullQueryBuilder in project blaze-persistence by Blazebit.

the class ViewTypeObjectBuilder method applySelects.

@Override
public <X extends SelectBuilder<X>> void applySelects(X queryBuilder) {
    if (fetches.isEmpty()) {
        if (secondaryMappers.length != 0) {
            FullQueryBuilder<?, ?> fullQueryBuilder = (FullQueryBuilder<?, ?>) queryBuilder;
            for (SecondaryMapper viewRoot : secondaryMappers) {
                viewRoot.apply(fullQueryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro);
            }
        }
        for (int i = 0; i < mappers.length; i++) {
            mappers[i].applyMapping(queryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro, false);
        }
    } else {
        if (secondaryMappers.length != 0) {
            FullQueryBuilder<?, ?> fullQueryBuilder = (FullQueryBuilder<?, ?>) queryBuilder;
            for (SecondaryMapper viewRoot : secondaryMappers) {
                if (fetches.contains(viewRoot.getAttributePath())) {
                    viewRoot.apply(fullQueryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro);
                }
            }
        }
        for (int i = 0; i < mappers.length; i++) {
            TupleElementMapper mapper = mappers[i];
            String attributePath = mapper.getAttributePath();
            if (attributePath != null && fetches.contains(attributePath)) {
                mapper.applyMapping(queryBuilder, parameterHolder, optionalParameters, viewJpqlMacro, embeddingViewJpqlMacro, false);
            } else {
                queryBuilder.select("NULL");
            }
        }
    }
}
Also used : FullQueryBuilder(com.blazebit.persistence.FullQueryBuilder) TupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.TupleElementMapper)

Aggregations

FullQueryBuilder (com.blazebit.persistence.FullQueryBuilder)6 FinalSetOperationCTECriteriaBuilder (com.blazebit.persistence.FinalSetOperationCTECriteriaBuilder)2 LimitBuilder (com.blazebit.persistence.LimitBuilder)2 MultipleSubqueryInitiator (com.blazebit.persistence.MultipleSubqueryInitiator)2 SubqueryInitiator (com.blazebit.persistence.SubqueryInitiator)2 TupleTransformator (com.blazebit.persistence.view.impl.objectbuilder.transformator.TupleTransformator)2 JoinExpression (com.querydsl.core.JoinExpression)2 Path (com.querydsl.core.types.Path)2 SubQueryExpression (com.querydsl.core.types.SubQueryExpression)2 BeanPath (com.querydsl.core.types.dsl.BeanPath)2 BaseOngoingFinalSetOperationBuilder (com.blazebit.persistence.BaseOngoingFinalSetOperationBuilder)1 BaseOngoingSetOperationBuilder (com.blazebit.persistence.BaseOngoingSetOperationBuilder)1 BaseSubqueryBuilder (com.blazebit.persistence.BaseSubqueryBuilder)1 DistinctBuilder (com.blazebit.persistence.DistinctBuilder)1 FinalSetOperationCriteriaBuilder (com.blazebit.persistence.FinalSetOperationCriteriaBuilder)1 FinalSetOperationSubqueryBuilder (com.blazebit.persistence.FinalSetOperationSubqueryBuilder)1 From (com.blazebit.persistence.From)1 FromBuilder (com.blazebit.persistence.FromBuilder)1 FullSelectCTECriteriaBuilder (com.blazebit.persistence.FullSelectCTECriteriaBuilder)1 GroupByBuilder (com.blazebit.persistence.GroupByBuilder)1