use of org.hibernate.query.sqm.tree.expression.SqmCollectionSize in project hibernate-orm by hibernate.
the class WhereClauseTests method testCollectionSizeFunction.
@Test
public void testCollectionSizeFunction() {
SqmSelectStatement<?> statement = interpretSelect("SELECT t FROM EntityOfSets t WHERE SIZE( t.setOfBasics ) = 311");
SqmPredicate predicate = statement.getQuerySpec().getWhereClause().getPredicate();
assertThat(predicate, instanceOf(SqmComparisonPredicate.class));
SqmComparisonPredicate relationalPredicate = ((SqmComparisonPredicate) predicate);
assertThat(relationalPredicate.getSqmOperator(), is(ComparisonOperator.EQUAL));
assertThat(relationalPredicate.getRightHandExpression(), instanceOf(SqmLiteral.class));
assertThat(((SqmLiteral<?>) relationalPredicate.getRightHandExpression()).getLiteralValue(), is(311));
assertThat(relationalPredicate.getLeftHandExpression(), instanceOf(SqmCollectionSize.class));
final SqmCollectionSize func = (SqmCollectionSize) relationalPredicate.getLeftHandExpression();
assertThat(func.getPluralPath().getLhs().getExplicitAlias(), is("t"));
assertThat(func.getPluralPath().getReferencedPathSource().getPathName(), is("setOfBasics"));
}
Aggregations