Top Description Fields Constructors Methods
org.hibernate.query.criteria.internal.predicate

public Class CompoundPredicate

extends AbstractPredicateImpl
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, java.util.ArrayList, .Arrays, .List, javax.persistence.criteria.Expression, .Predicate, org.hibernate.query.criteria.internal.CriteriaBuilderImpl, .ParameterRegistry, .Renderable, org.hibernate.query.criteria.internal.compile.RenderingContext

A compound predicate is a grouping of other predicates in order to convert either a conjunction (logical AND) or a disjunction (logical OR).
Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final List<Expression<Boolean>>
private Predicate.BooleanOperator

Constructor Summary

AccessConstructor and Description
public
CompoundPredicate(CriteriaBuilderImpl
The query builder from which this originates.
criteriaBuilder
,
Predicate.BooleanOperator
Indicates whether this predicate will function as a conjunction or disjunction.
operator
)

Constructs an empty conjunction or disjunction.

public
CompoundPredicate(CriteriaBuilderImpl
The query builder from which this originates.
criteriaBuilder
,
Predicate.BooleanOperator
Indicates whether this predicate will function as a conjunction or disjunction.
operator
,
Expression<Boolean>...
The expressions to be grouped.
expressions
)

Constructs a conjunction or disjunction over the given expressions.

public
CompoundPredicate(CriteriaBuilderImpl
The query builder from which this originates.
criteriaBuilder
,
Predicate.BooleanOperator
Indicates whether this predicate will function as a conjunction or disjunction.
operator
,
List<Expression<Boolean>>
The expressions to be grouped.
expressions
)

Constructs a conjunction or disjunction over the given expressions.

Method Summary

Modifier and TypeMethod and Description
private void
private void
public List<Expression<Boolean>>
getExpressions()

Implements javax.persistence.criteria.Predicate.getExpressions.

Return the top-level conjuncts or disjuncts of the predicate.
public Predicate.BooleanOperator
getOperator()

Implements javax.persistence.criteria.Predicate.getOperator.

Return the boolean operator for the predicate.
public boolean
public Predicate
not()

Overrides org.hibernate.query.criteria.internal.predicate.AbstractPredicateImpl.not.

Implements javax.persistence.criteria.Predicate.not.

Create negation of compound predicate by using logic rules: 1.
private static String
public void
registerParameters(ParameterRegistry
The parameter registry with which to register.
registry
)

Implements org.hibernate.query.criteria.internal.ParameterContainer.registerParameters.

Register any parameters contained within this query component with the given registry.
public String
render(RenderingContext renderingContext)

Implements org.hibernate.query.criteria.internal.Renderable.render.

Perform the rendering, returning the rendition
public String
render(boolean
Should the predicate be negated.
isNegated
,
RenderingContext
The context for rendering
renderingContext
)

Implements org.hibernate.query.criteria.internal.predicate.PredicateImplementor.render.

Form of Renderable#render used when the predicate is wrapped in a negated wrapper.
public static String
render(PredicateImplementor predicate, RenderingContext renderingContext)

public static Predicate.BooleanOperator
private void
Inherited from org.hibernate.query.criteria.internal.predicate.AbstractPredicateImpl:
getCompoundSelectionItemsisCompoundSelectionisNegated

Field Detail

expressionsback to summary
private final List<Expression<Boolean>> expressions
operatorback to summary
private Predicate.BooleanOperator operator

Constructor Detail

CompoundPredicateback to summary
public CompoundPredicate(CriteriaBuilderImpl criteriaBuilder, Predicate.BooleanOperator operator)

Constructs an empty conjunction or disjunction.

Parameters
criteriaBuilder:CriteriaBuilderImpl

The query builder from which this originates.

operator:Predicate.BooleanOperator

Indicates whether this predicate will function as a conjunction or disjunction.

CompoundPredicateback to summary
public CompoundPredicate(CriteriaBuilderImpl criteriaBuilder, Predicate.BooleanOperator operator, Expression<Boolean>... expressions)

Constructs a conjunction or disjunction over the given expressions.

Parameters
criteriaBuilder:CriteriaBuilderImpl

The query builder from which this originates.

operator:Predicate.BooleanOperator

Indicates whether this predicate will function as a conjunction or disjunction.

expressions:Expression<Boolean>[]

The expressions to be grouped.

CompoundPredicateback to summary
public CompoundPredicate(CriteriaBuilderImpl criteriaBuilder, Predicate.BooleanOperator operator, List<Expression<Boolean>> expressions)

Constructs a conjunction or disjunction over the given expressions.

Parameters
criteriaBuilder:CriteriaBuilderImpl

The query builder from which this originates.

operator:Predicate.BooleanOperator

Indicates whether this predicate will function as a conjunction or disjunction.

expressions:List<Expression<Boolean>>

The expressions to be grouped.

Method Detail

applyExpressionsback to summary
private void applyExpressions(Expression<Boolean>... expressions)
applyExpressionsback to summary
private void applyExpressions(List<Expression<Boolean>> expressions)
getExpressionsback to summary
public List<Expression<Boolean>> getExpressions()

Implements javax.persistence.criteria.Predicate.getExpressions.

Doc from javax.persistence.criteria.Predicate.getExpressions.

Return the top-level conjuncts or disjuncts of the predicate. Returns empty list if there are no top-level conjuncts or disjuncts of the predicate. Modifications to the list do not affect the query.

Returns:List<Expression<Boolean>>

list of boolean expressions forming the predicate

Annotations
@Override
getOperatorback to summary
public Predicate.BooleanOperator getOperator()

Implements javax.persistence.criteria.Predicate.getOperator.

Doc from javax.persistence.criteria.Predicate.getOperator.

Return the boolean operator for the predicate. If the predicate is simple, this is AND.

Returns:Predicate.BooleanOperator

boolean operator for the predicate

Annotations
@Override
isJunctionback to summary
public boolean isJunction()

Implements org.hibernate.query.criteria.internal.predicate.PredicateImplementor.isJunction.

Doc from org.hibernate.query.criteria.internal.predicate.PredicateImplementor.isJunction.

Is this a conjunction or disjunction?

Returns:boolean

true if this predicate is a junction (AND/OR); false otherwise

Annotations
@Override
notback to summary
public Predicate not()

Overrides org.hibernate.query.criteria.internal.predicate.AbstractPredicateImpl.not.

Implements javax.persistence.criteria.Predicate.not.

Create negation of compound predicate by using logic rules: 1. not (x || y) is (not x && not y) 2. not (x && y) is (not x || not y)

Returns:Predicate

Doc from javax.persistence.criteria.Predicate.not.

negated predicate

Annotations
@Override
operatorTextWithSeparatorback to summary
private static String operatorTextWithSeparator(Predicate.BooleanOperator operator)
registerParametersback to summary
public void registerParameters(ParameterRegistry registry)

Implements org.hibernate.query.criteria.internal.ParameterContainer.registerParameters.

Doc from org.hibernate.query.criteria.internal.ParameterContainer.registerParameters.

Register any parameters contained within this query component with the given registry.

Parameters
registry:ParameterRegistry

The parameter registry with which to register.

Annotations
@Override
renderback to summary
public String render(RenderingContext renderingContext)

Implements org.hibernate.query.criteria.internal.Renderable.render.

Doc from org.hibernate.query.criteria.internal.Renderable.render.

Perform the rendering, returning the rendition

Annotations
@Override
renderback to summary
public String render(boolean isNegated, RenderingContext renderingContext)

Implements org.hibernate.query.criteria.internal.predicate.PredicateImplementor.render.

Doc from org.hibernate.query.criteria.internal.predicate.PredicateImplementor.render.

Form of Renderable#render used when the predicate is wrapped in a negated wrapper. Allows passing down the negation flag.

Note that this form is no-op in compound (junction) predicates. The reason being that compound predicates are more complex and the negation is applied during its creation.

Parameters
isNegated:boolean

Should the predicate be negated.

renderingContext:RenderingContext

The context for rendering

Returns:String

The rendered predicate fragment.

Annotations
@Override
renderback to summary
public static String render(PredicateImplementor predicate, RenderingContext renderingContext)
reverseOperatorback to summary
public static Predicate.BooleanOperator reverseOperator(Predicate.BooleanOperator operator)
toggleOperatorback to summary
private void toggleOperator()