use of com.blazebit.persistence.view.impl.objectbuilder.mapper.ParameterizedAliasSubqueryTupleElementMapper 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);
}
Aggregations