CompoundPredicate hibernate to support XOR operations


#1

Hi,

I am new to Hibernate and working on complex requirement where logical operations are very critical.
I am referring the below code :

public Predicate isFalse(Expression expression) {
if ( CompoundPredicate.class.isInstance( expression ) ) {
final CompoundPredicate predicate = (CompoundPredicate) expression;
if ( predicate.getExpressions().size() == 0 ) {
return new BooleanStaticAssertionPredicate(
this,
predicate.getOperator() == Predicate.BooleanOperator.OR
);
}
predicate.not();
return predicate;
}
else if ( Predicate.class.isInstance( expression ) ) {
final Predicate predicate = (Predicate) expression;
predicate.not();
return predicate;
}
return new BooleanAssertionPredicate( this, expression, Boolean.FALSE );
}

I am trying to understand if compoundPredicate it provides XOR operation as well.

Source of the above code :Compound Predicate Example