Search in sources :

Example 1 with ExpressionBuilder

use of com.blazebit.persistence.impl.builder.expression.ExpressionBuilder in project blaze-persistence by Blazebit.

the class SelectManager method selectSubqueries.

<X> MultipleSubqueryInitiator<X> selectSubqueries(X builder, Expression expression, final String selectAlias) {
    verifyBuilderEnded();
    clearDefaultSelects();
    MultipleSubqueryInitiator<X> initiator = new MultipleSubqueryInitiatorImpl<X>(builder, expression, new ExpressionBuilderEndedListener() {

        @Override
        public void onBuilderEnded(ExpressionBuilder builder) {
            select(builder.getExpression(), selectAlias);
        }
    }, subqueryInitFactory, ClauseType.SELECT);
    return initiator;
}
Also used : ExpressionBuilderEndedListener(com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener) ExpressionBuilder(com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)

Example 2 with ExpressionBuilder

use of com.blazebit.persistence.impl.builder.expression.ExpressionBuilder in project blaze-persistence by Blazebit.

the class RestrictionBuilderImpl method simpleMultipleBuilder.

private <X> MultipleSubqueryInitiator<X> simpleMultipleBuilder(X result, Expression expr, final AbstractQuantifiablePredicateBuilder predicateBuilder) {
    MultipleSubqueryInitiatorImpl<X> initiator = new MultipleSubqueryInitiatorImpl<X>(result, expr, new ExpressionBuilderEndedListener() {

        @Override
        public void onBuilderEnded(ExpressionBuilder builder) {
            RestrictionBuilderImpl.this.predicate = predicateBuilder.createPredicate(leftExpression, builder.getExpression(), PredicateQuantifier.ONE);
            listener.onBuilderEnded(RestrictionBuilderImpl.this);
        }
    }, subqueryInitFactory, clause);
    startBuilder(predicateBuilder);
    predicateBuilder.startBuilder(initiator);
    return initiator;
}
Also used : ExpressionBuilderEndedListener(com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) ExpressionBuilder(com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)

Example 3 with ExpressionBuilder

use of com.blazebit.persistence.impl.builder.expression.ExpressionBuilder in project blaze-persistence by Blazebit.

the class WhereAndBuilderImpl method whereExpressionSubqueries.

@Override
public MultipleSubqueryInitiator<WhereAndBuilder<T>> whereExpressionSubqueries(String expression) {
    Predicate predicate = expressionFactory.createBooleanExpression(expression, true);
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<WhereAndBuilder<T>> initiator = new MultipleSubqueryInitiatorImpl<WhereAndBuilder<T>>(this, predicate, new ExpressionBuilderEndedListener() {

        @Override
        public void onBuilderEnded(ExpressionBuilder builder) {
            WhereAndBuilderImpl.this.predicate.getChildren().add((Predicate) builder.getExpression());
            currentMultipleSubqueryInitiator = null;
        }
    }, subqueryInitFactory, ClauseType.WHERE);
    currentMultipleSubqueryInitiator = initiator;
    return initiator;
}
Also used : ExpressionBuilderEndedListener(com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) WhereAndBuilder(com.blazebit.persistence.WhereAndBuilder) ExpressionBuilder(com.blazebit.persistence.impl.builder.expression.ExpressionBuilder) Predicate(com.blazebit.persistence.parser.predicate.Predicate) CompoundPredicate(com.blazebit.persistence.parser.predicate.CompoundPredicate) ExistsPredicate(com.blazebit.persistence.parser.predicate.ExistsPredicate)

Example 4 with ExpressionBuilder

use of com.blazebit.persistence.impl.builder.expression.ExpressionBuilder in project blaze-persistence by Blazebit.

the class BetweenBuilderImpl method startMultipleSubqueryInitiator.

private MultipleSubqueryInitiator<T> startMultipleSubqueryInitiator(Expression expression) {
    verifySubqueryBuilderEnded();
    MultipleSubqueryInitiator<T> initiator = new MultipleSubqueryInitiatorImpl<T>(result, expression, new ExpressionBuilderEndedListener() {

        @Override
        public void onBuilderEnded(ExpressionBuilder builder) {
            predicate = new BetweenPredicate(left, start, builder.getExpression(), negated);
            listener.onBuilderEnded(BetweenBuilderImpl.this);
        }
    }, subqueryInitFactory, clauseType);
    return initiator;
}
Also used : ExpressionBuilderEndedListener(com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener) BetweenPredicate(com.blazebit.persistence.parser.predicate.BetweenPredicate) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) ExpressionBuilder(com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)

Example 5 with ExpressionBuilder

use of com.blazebit.persistence.impl.builder.expression.ExpressionBuilder in project blaze-persistence by Blazebit.

the class HavingAndBuilderImpl method havingExpressionSubqueries.

@Override
public MultipleSubqueryInitiator<HavingAndBuilder<T>> havingExpressionSubqueries(String expression) {
    Predicate predicate = expressionFactory.createBooleanExpression(expression, true);
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<HavingAndBuilder<T>> initiator = new MultipleSubqueryInitiatorImpl<HavingAndBuilder<T>>(this, predicate, new ExpressionBuilderEndedListener() {

        @Override
        public void onBuilderEnded(ExpressionBuilder builder) {
            HavingAndBuilderImpl.this.predicate.getChildren().add((Predicate) builder.getExpression());
            currentMultipleSubqueryInitiator = null;
        }
    }, subqueryInitFactory, ClauseType.HAVING);
    currentMultipleSubqueryInitiator = initiator;
    return initiator;
}
Also used : ExpressionBuilderEndedListener(com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener) HavingAndBuilder(com.blazebit.persistence.HavingAndBuilder) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) ExpressionBuilder(com.blazebit.persistence.impl.builder.expression.ExpressionBuilder) Predicate(com.blazebit.persistence.parser.predicate.Predicate) CompoundPredicate(com.blazebit.persistence.parser.predicate.CompoundPredicate) ExistsPredicate(com.blazebit.persistence.parser.predicate.ExistsPredicate)

Aggregations

ExpressionBuilder (com.blazebit.persistence.impl.builder.expression.ExpressionBuilder)14 ExpressionBuilderEndedListener (com.blazebit.persistence.impl.builder.expression.ExpressionBuilderEndedListener)14 MultipleSubqueryInitiatorImpl (com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl)11 CompoundPredicate (com.blazebit.persistence.parser.predicate.CompoundPredicate)10 ExistsPredicate (com.blazebit.persistence.parser.predicate.ExistsPredicate)10 Predicate (com.blazebit.persistence.parser.predicate.Predicate)10 RootPredicate (com.blazebit.persistence.impl.builder.predicate.RootPredicate)2 List (java.util.List)2 HavingAndBuilder (com.blazebit.persistence.HavingAndBuilder)1 HavingOrBuilder (com.blazebit.persistence.HavingOrBuilder)1 JoinOnAndBuilder (com.blazebit.persistence.JoinOnAndBuilder)1 JoinOnBuilder (com.blazebit.persistence.JoinOnBuilder)1 JoinOnOrBuilder (com.blazebit.persistence.JoinOnOrBuilder)1 WhereAndBuilder (com.blazebit.persistence.WhereAndBuilder)1 WhereOrBuilder (com.blazebit.persistence.WhereOrBuilder)1 Expression (com.blazebit.persistence.parser.expression.Expression)1 ParameterExpression (com.blazebit.persistence.parser.expression.ParameterExpression)1 PathExpression (com.blazebit.persistence.parser.expression.PathExpression)1 SubqueryExpression (com.blazebit.persistence.parser.expression.SubqueryExpression)1 BetweenPredicate (com.blazebit.persistence.parser.predicate.BetweenPredicate)1