use of org.hibernate.query.sqm.tree.domain.SqmPath in project hibernate-orm by hibernate.
the class SelectClauseTests method testBinaryArithmeticExpressionWithMultipleFromSpaces.
@Test
public void testBinaryArithmeticExpressionWithMultipleFromSpaces() {
final String query = "select p.numberOfToes + p2.numberOfToes as b from Person p, Person p2";
final SqmSelectStatement<?> selectStatement = interpretSelect(query);
final SqmQuerySpec<?> querySpec = selectStatement.getQuerySpec();
final SqmSelection<?> selection = querySpec.getSelectClause().getSelections().get(0);
assertThat(querySpec.getFromClause().getRoots().size(), is(2));
final SqmRoot<?> entityRoot = querySpec.getFromClause().getRoots().get(0);
assertThat(entityRoot.getEntityName(), endsWith("Person"));
final SqmRoot<?> entity2Root = querySpec.getFromClause().getRoots().get(1);
assertThat(entity2Root.getEntityName(), endsWith("Person"));
SqmBinaryArithmetic addExpression = (SqmBinaryArithmetic) selection.getSelectableNode();
SqmPath<?> leftHandOperand = (SqmPath<?>) addExpression.getLeftHandOperand();
assertThat(leftHandOperand.getLhs(), sameInstance(entityRoot));
assertThat(leftHandOperand.getReferencedPathSource().getPathName(), is("numberOfToes"));
SqmPath<?> rightHandOperand = (SqmPath<?>) addExpression.getRightHandOperand();
assertThat(rightHandOperand.getLhs(), sameInstance(entity2Root));
assertThat(rightHandOperand.getReferencedPathSource().getPathName(), is("numberOfToes"));
}
Aggregations