@Override public Condition interpretInternal() throws QueryException { String propertyValuePath = getHqlDataInstance().getHqlPath(); if (filter.getRightHandSidePath() != null) { return createPropertyVsPropertyCondition(propertyValuePath); } else { Object value = RAnyConverter.getAggregatedRepoObject(getValue(filter)); Condition c = createPropertyVsConstantCondition(propertyValuePath, value, filter); return addIsNotNullIfNecessary(c, propertyValuePath); } } }
@Override public Condition interpretInternal() throws QueryException { if (linkDefinition.getTargetDefinition().isLob()) { throw new QueryException("Can't query based on clob property value '" + linkDefinition + "'."); } String propertyValuePath = getHqlDataInstance().getHqlPath(); if (filter.getRightHandSidePath() != null) { return createPropertyVsPropertyCondition(propertyValuePath); } else { Object value = getValueFromFilter(filter); Condition condition = createPropertyVsConstantCondition(propertyValuePath, value, filter); return addIsNotNullIfNecessary(condition, propertyValuePath); } }
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(); // TODO take data types into account, e.g. // PolyString vs PolyString // PolyString vs String (and vice versa) // non-string extension items vs non-string static items // // And also take matching rules into account as well. if (filter instanceof EqualFilter) { // left = right OR (left IS NULL AND right IS NULL) 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); } }