Search in sources :

Example 6 with RestrictionBuilder

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

the class WhereAndBuilderImpl method whereSubqueries.

@Override
public MultipleSubqueryInitiator<RestrictionBuilder<WhereAndBuilder<T>>> whereSubqueries(String expression) {
    Expression expr = expressionFactory.createSimpleExpression(expression, true);
    RestrictionBuilderImpl<WhereAndBuilder<T>> restrictionBuilder = startBuilder(new RestrictionBuilderImpl<WhereAndBuilder<T>>(this, this, subqueryInitFactory, expressionFactory, parameterManager, ClauseType.WHERE));
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<RestrictionBuilder<WhereAndBuilder<T>>> initiator = new MultipleSubqueryInitiatorImpl<RestrictionBuilder<WhereAndBuilder<T>>>(restrictionBuilder, expr, new RestrictionBuilderExpressionBuilderListener(restrictionBuilder), subqueryInitFactory, ClauseType.WHERE);
    return initiator;
}
Also used : Expression(com.blazebit.persistence.parser.expression.Expression) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) WhereAndBuilder(com.blazebit.persistence.WhereAndBuilder) RestrictionBuilderExpressionBuilderListener(com.blazebit.persistence.impl.RestrictionBuilderExpressionBuilderListener) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Example 7 with RestrictionBuilder

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

the class FilterTest method verifyLikeFilter.

@SuppressWarnings({ "rawtypes", "unchecked" })
public RestrictionBuilder<?> verifyLikeFilter(AttributeFilterProvider<?> filter, String expression) {
    WhereBuilder whereBuilder = Mockito.mock(WhereBuilder.class);
    RestrictionBuilder rb = Mockito.mock(RestrictionBuilder.class, Mockito.RETURNS_DEEP_STUBS);
    EscapeBuilder eb = Mockito.mock(EscapeBuilder.class);
    LikeBuilder lb = Mockito.mock(LikeBuilder.class);
    Mockito.when(whereBuilder.where(expression)).thenReturn(rb);
    Mockito.when(rb.like()).thenReturn(lb);
    Mockito.when(rb.like(false)).thenReturn(lb);
    Mockito.when(lb.value("%" + value)).thenReturn(eb);
    Mockito.when(lb.value(value + "%")).thenReturn(eb);
    Mockito.when(lb.value("%" + value + "%")).thenReturn(eb);
    Mockito.when(eb.noEscape()).thenReturn(whereBuilder);
    filter.apply(whereBuilder, expression);
    return rb;
}
Also used : LikeBuilder(com.blazebit.persistence.LikeBuilder) WhereBuilder(com.blazebit.persistence.WhereBuilder) EscapeBuilder(com.blazebit.persistence.EscapeBuilder) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Example 8 with RestrictionBuilder

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

the class HavingOrBuilderImpl method havingSubqueries.

@Override
public MultipleSubqueryInitiator<RestrictionBuilder<HavingOrBuilder<T>>> havingSubqueries(String expression) {
    Expression expr = expressionFactory.createSimpleExpression(expression, true);
    RestrictionBuilderImpl<HavingOrBuilder<T>> restrictionBuilder = startBuilder(new RestrictionBuilderImpl<HavingOrBuilder<T>>(this, this, subqueryInitFactory, expressionFactory, parameterManager, ClauseType.HAVING));
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<RestrictionBuilder<HavingOrBuilder<T>>> initiator = new MultipleSubqueryInitiatorImpl<RestrictionBuilder<HavingOrBuilder<T>>>(restrictionBuilder, expr, new RestrictionBuilderExpressionBuilderListener(restrictionBuilder), subqueryInitFactory, ClauseType.HAVING);
    return initiator;
}
Also used : HavingOrBuilder(com.blazebit.persistence.HavingOrBuilder) Expression(com.blazebit.persistence.parser.expression.Expression) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) RestrictionBuilderExpressionBuilderListener(com.blazebit.persistence.impl.RestrictionBuilderExpressionBuilderListener) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Example 9 with RestrictionBuilder

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

the class JoinOnAndBuilderImpl method onSubqueries.

@Override
public MultipleSubqueryInitiator<RestrictionBuilder<JoinOnAndBuilder<T>>> onSubqueries(String expression) {
    Expression expr = expressionFactory.createSimpleExpression(expression, true);
    RestrictionBuilderImpl<JoinOnAndBuilder<T>> restrictionBuilder = startBuilder(new RestrictionBuilderImpl<JoinOnAndBuilder<T>>(this, this, subqueryInitFactory, expressionFactory, parameterManager, ClauseType.JOIN));
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<RestrictionBuilder<JoinOnAndBuilder<T>>> initiator = new MultipleSubqueryInitiatorImpl<RestrictionBuilder<JoinOnAndBuilder<T>>>(restrictionBuilder, expr, new RestrictionBuilderExpressionBuilderListener(restrictionBuilder), subqueryInitFactory, ClauseType.JOIN);
    return initiator;
}
Also used : Expression(com.blazebit.persistence.parser.expression.Expression) JoinOnAndBuilder(com.blazebit.persistence.JoinOnAndBuilder) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) RestrictionBuilderExpressionBuilderListener(com.blazebit.persistence.impl.RestrictionBuilderExpressionBuilderListener) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Example 10 with RestrictionBuilder

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

the class JoinOnOrBuilderImpl method onSubqueries.

@Override
public MultipleSubqueryInitiator<RestrictionBuilder<JoinOnOrBuilder<T>>> onSubqueries(String expression) {
    Expression expr = expressionFactory.createSimpleExpression(expression, true);
    RestrictionBuilderImpl<JoinOnOrBuilder<T>> restrictionBuilder = startBuilder(new RestrictionBuilderImpl<JoinOnOrBuilder<T>>(this, this, subqueryInitFactory, expressionFactory, parameterManager, ClauseType.JOIN));
    // We don't need a listener or marker here, because the resulting restriction builder can only be ended, when the initiator is ended
    MultipleSubqueryInitiator<RestrictionBuilder<JoinOnOrBuilder<T>>> initiator = new MultipleSubqueryInitiatorImpl<RestrictionBuilder<JoinOnOrBuilder<T>>>(restrictionBuilder, expr, new RestrictionBuilderExpressionBuilderListener(restrictionBuilder), subqueryInitFactory, ClauseType.JOIN);
    return initiator;
}
Also used : JoinOnOrBuilder(com.blazebit.persistence.JoinOnOrBuilder) Expression(com.blazebit.persistence.parser.expression.Expression) MultipleSubqueryInitiatorImpl(com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl) RestrictionBuilderExpressionBuilderListener(com.blazebit.persistence.impl.RestrictionBuilderExpressionBuilderListener) RestrictionBuilder(com.blazebit.persistence.RestrictionBuilder)

Aggregations

RestrictionBuilder (com.blazebit.persistence.RestrictionBuilder)13 Expression (com.blazebit.persistence.parser.expression.Expression)10 MultipleSubqueryInitiatorImpl (com.blazebit.persistence.impl.MultipleSubqueryInitiatorImpl)7 RestrictionBuilderExpressionBuilderListener (com.blazebit.persistence.impl.RestrictionBuilderExpressionBuilderListener)7 RestrictionBuilderImpl (com.blazebit.persistence.impl.builder.predicate.RestrictionBuilderImpl)4 CaseExpressionBuilderListener (com.blazebit.persistence.impl.builder.predicate.CaseExpressionBuilderListener)2 SuperExpressionLeftHandsideSubqueryPredicateBuilder (com.blazebit.persistence.impl.builder.predicate.SuperExpressionLeftHandsideSubqueryPredicateBuilder)2 EscapeBuilder (com.blazebit.persistence.EscapeBuilder)1 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 LikeBuilder (com.blazebit.persistence.LikeBuilder)1 WhereAndBuilder (com.blazebit.persistence.WhereAndBuilder)1 WhereBuilder (com.blazebit.persistence.WhereBuilder)1 WhereOrBuilder (com.blazebit.persistence.WhereOrBuilder)1