Search in sources :

Example 1 with SimpleQueryGenerator

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

the class AbstractAttribute method renderExpression.

protected final void renderExpression(String parent, Expression expression, String aliasToSkip, ServiceProvider serviceProvider, StringBuilder sb) {
    if (parent != null && !parent.isEmpty()) {
        ExpressionFactory ef = serviceProvider.getService(ExpressionFactory.class);
        SimpleQueryGenerator generator = new PrefixingQueryGenerator(ef, parent, aliasToSkip, aliasToSkip, declaringType.getEntityViewRootTypes().keySet(), true, false);
        generator.setQueryBuffer(sb);
        expression.accept(generator);
    } else {
        sb.append(expression);
    }
}
Also used : ExpressionFactory(com.blazebit.persistence.parser.expression.ExpressionFactory) PrefixingQueryGenerator(com.blazebit.persistence.view.impl.PrefixingQueryGenerator) SimpleQueryGenerator(com.blazebit.persistence.parser.SimpleQueryGenerator)

Example 2 with SimpleQueryGenerator

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

the class TupleElementMapperBuilder method applyMapping.

private void applyMapping(StringBuilder sb, String prefixParts, String mapping) {
    if (mapping.isEmpty()) {
        if (prefixParts != null && !prefixParts.isEmpty()) {
            sb.append(AbstractAttribute.stripThisFromMapping(prefixParts));
        }
        return;
    }
    if (prefixParts != null && !prefixParts.isEmpty()) {
        Expression expr = ef.createSimpleExpression(mapping, false, false, true);
        SimpleQueryGenerator generator = new PrefixingQueryGenerator(ef, prefixParts, null, null, rootTypes.keySet(), true, false);
        generator.setQueryBuffer(sb);
        expr.accept(generator);
    } else {
        sb.append(mapping);
    }
}
Also used : Expression(com.blazebit.persistence.parser.expression.Expression) PrefixingQueryGenerator(com.blazebit.persistence.view.impl.PrefixingQueryGenerator) SimpleQueryGenerator(com.blazebit.persistence.parser.SimpleQueryGenerator)

Example 3 with SimpleQueryGenerator

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

the class PrefixingQueryGenerator method prefix.

public static String prefix(ExpressionFactory ef, Expression expression, String prefix, Set<String> queryAliases, boolean fromEmbeddingViewScope) {
    SimpleQueryGenerator generator = new PrefixingQueryGenerator(ef, prefix, null, null, queryAliases, !fromEmbeddingViewScope, fromEmbeddingViewScope);
    StringBuilder sb = new StringBuilder(20 + prefix.length());
    generator.setQueryBuffer(sb);
    expression.accept(generator);
    return sb.toString();
}
Also used : SimpleQueryGenerator(com.blazebit.persistence.parser.SimpleQueryGenerator)

Example 4 with SimpleQueryGenerator

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

the class TupleElementMapperBuilder method getMapping.

public String getMapping(Expression expression) {
    StringBuilder sb = new StringBuilder();
    if (mappingPrefix != null && !mappingPrefix.isEmpty()) {
        SimpleQueryGenerator generator = new PrefixingQueryGenerator(ef, mappingPrefix, null, null, rootTypes.keySet(), true, false);
        generator.setQueryBuffer(sb);
        expression.accept(generator);
    } else {
        sb.append(expression);
    }
    return sb.toString().intern();
}
Also used : PrefixingQueryGenerator(com.blazebit.persistence.view.impl.PrefixingQueryGenerator) SimpleQueryGenerator(com.blazebit.persistence.parser.SimpleQueryGenerator)

Aggregations

SimpleQueryGenerator (com.blazebit.persistence.parser.SimpleQueryGenerator)4 PrefixingQueryGenerator (com.blazebit.persistence.view.impl.PrefixingQueryGenerator)3 Expression (com.blazebit.persistence.parser.expression.Expression)1 ExpressionFactory (com.blazebit.persistence.parser.expression.ExpressionFactory)1