protected Condition createPropertyVsPropertyCondition(String leftPropertyValuePath) throws QueryException {
HqlDataInstance rightItem = getItemPathResolver().resolveItemPath(filter.getRightHandSidePath(),
filter.getRightHandSideDefinition(), getBaseHqlEntityForChildren(), true);
String rightHqlPath = rightItem.getHqlPath();
RootHibernateQuery hibernateQuery = context.getHibernateQuery();
if (filter instanceof EqualFilter) {
Condition condition = hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, "=", false);
OrCondition orCondition = hibernateQuery.createOr(
condition,
hibernateQuery.createAnd(
hibernateQuery.createIsNull(leftPropertyValuePath),
hibernateQuery.createIsNull(rightHqlPath)
)
);
return orCondition;
} else if (filter instanceof ComparativeFilter) {
ItemRestrictionOperation operation = findOperationForFilter(filter);
Condition condition = hibernateQuery.createCompareXY(leftPropertyValuePath, rightHqlPath, operation.symbol(), false);
return condition;
} else {
throw new QueryException("Right-side ItemPath is supported currently only for EqualFilter or ComparativeFilter, not for " + filter);
}
}