Search in sources :

Example 1 with SimpleSubqueryTupleElementMapper

use of com.blazebit.persistence.view.impl.objectbuilder.mapper.SimpleSubqueryTupleElementMapper in project blaze-persistence by Blazebit.

the class ViewTypeObjectBuilderTemplate method applySubqueryMapping.

private void applySubqueryMapping(SubqueryAttribute<?, ?> attribute, String attributePath, TupleElementMapperBuilder mapperBuilder, EmbeddingViewJpqlMacro embeddingViewJpqlMacro) {
    SubqueryProviderFactory factory = attribute.getSubqueryProviderFactory();
    String alias = mapperBuilder.getAlias(attribute, false);
    String subqueryAlias = attribute.getSubqueryAlias();
    String viewPath = mapperBuilder.getMapping();
    String subqueryExpression = attribute.getSubqueryExpression();
    TupleElementMapper mapper;
    if (subqueryExpression.isEmpty()) {
        if (alias != null) {
            if (factory.isParameterized()) {
                mapper = new ParameterizedAliasSubqueryTupleElementMapper(attribute.getType(), factory, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath(), alias);
            } else {
                mapper = new AliasSubqueryTupleElementMapper(attribute.getType(), factory.create(null, null), attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath(), alias);
            }
        } else {
            if (factory.isParameterized()) {
                mapper = new ParameterizedSubqueryTupleElementMapper(attribute.getType(), factory, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath());
            } else {
                mapper = new SimpleSubqueryTupleElementMapper(attribute.getType(), factory.create(null, null), attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath());
            }
        }
    } else {
        subqueryExpression = mapperBuilder.getMapping(attribute);
        if (alias != null) {
            if (factory.isParameterized()) {
                mapper = new ParameterizedAliasExpressionSubqueryTupleElementMapper(attribute.getType(), factory, subqueryExpression, subqueryAlias, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath(), alias);
            } else {
                mapper = new AliasExpressionSubqueryTupleElementMapper(attribute.getType(), factory.create(null, null), subqueryExpression, subqueryAlias, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath(), alias);
            }
        } else {
            if (factory.isParameterized()) {
                mapper = new ParameterizedExpressionSubqueryTupleElementMapper(attribute.getType(), factory, subqueryExpression, subqueryAlias, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath());
            } else {
                mapper = new ExpressionSubqueryTupleElementMapper(attribute.getType(), factory.create(null, null), subqueryExpression, subqueryAlias, attributePath, viewPath, embeddingViewJpqlMacro.getEmbeddingViewPath());
            }
        }
    }
    mapperBuilder.addMapper(mapper);
}
Also used : ParameterizedExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionSubqueryTupleElementMapper) AliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionSubqueryTupleElementMapper) ParameterizedAliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasExpressionSubqueryTupleElementMapper) ExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionSubqueryTupleElementMapper) SubqueryProviderFactory(com.blazebit.persistence.view.SubqueryProviderFactory) ParameterizedAliasSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasSubqueryTupleElementMapper) ParameterizedAliasSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasSubqueryTupleElementMapper) AliasSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasSubqueryTupleElementMapper) ParameterizedSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedSubqueryTupleElementMapper) TupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.TupleElementMapper) ParameterizedExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionSubqueryTupleElementMapper) MultisetTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.MultisetTupleElementMapper) AliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionSubqueryTupleElementMapper) ParameterizedExpressionCorrelationJoinTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionCorrelationJoinTupleElementMapper) ParameterizedAliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasExpressionSubqueryTupleElementMapper) ParameterizedAliasSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasSubqueryTupleElementMapper) ExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionSubqueryTupleElementMapper) ExpressionTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionTupleElementMapper) CorrelationMultisetTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.CorrelationMultisetTupleElementMapper) SimpleSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.SimpleSubqueryTupleElementMapper) ExpressionCorrelationJoinTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionCorrelationJoinTupleElementMapper) AliasExpressionTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionTupleElementMapper) AliasSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasSubqueryTupleElementMapper) ConstrainedTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ConstrainedTupleElementMapper) SimpleSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.SimpleSubqueryTupleElementMapper) ParameterizedAliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasExpressionSubqueryTupleElementMapper) ParameterizedExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionSubqueryTupleElementMapper) AliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionSubqueryTupleElementMapper) ParameterizedAliasExpressionSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasExpressionSubqueryTupleElementMapper) ParameterizedSubqueryTupleElementMapper(com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedSubqueryTupleElementMapper)

Aggregations

SubqueryProviderFactory (com.blazebit.persistence.view.SubqueryProviderFactory)1 AliasExpressionSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionSubqueryTupleElementMapper)1 AliasExpressionTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasExpressionTupleElementMapper)1 AliasSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.AliasSubqueryTupleElementMapper)1 ConstrainedTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ConstrainedTupleElementMapper)1 CorrelationMultisetTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.CorrelationMultisetTupleElementMapper)1 ExpressionCorrelationJoinTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionCorrelationJoinTupleElementMapper)1 ExpressionSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionSubqueryTupleElementMapper)1 ExpressionTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ExpressionTupleElementMapper)1 MultisetTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.MultisetTupleElementMapper)1 ParameterizedAliasExpressionSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasExpressionSubqueryTupleElementMapper)1 ParameterizedAliasSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasSubqueryTupleElementMapper)1 ParameterizedExpressionCorrelationJoinTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionCorrelationJoinTupleElementMapper)1 ParameterizedExpressionSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedExpressionSubqueryTupleElementMapper)1 ParameterizedSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedSubqueryTupleElementMapper)1 SimpleSubqueryTupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.SimpleSubqueryTupleElementMapper)1 TupleElementMapper (com.blazebit.persistence.view.impl.objectbuilder.mapper.TupleElementMapper)1