src/app/n2n/impl/persistence/orm/property/relation/compare/ToManyCustomComparable.php
public function compareWith(QueryComparator $queryComparator, $operator, ComparisonStrategy $comparisonStrategy) {
		$this->validateOperator($operator);
		
		if ($comparisonStrategy->getType() != ComparisonStrategy::TYPE_COLUMN) {
			throw new CriteriaConflictException('Incompatible comparison');
		}
		
		$columnComparable = $comparisonStrategy->getColumnComparable();
		
		$oppositeOperator = null;
		$testTypeConstraint = null;
		switch ($operator) {
			case CriteriaComparator::OPERATOR_CONTAINS_ANY:
			case CriteriaComparator::OPERATOR_CONTAINS_NONE:
				$oppositeOperator = CriteriaComparator::OPERATOR_CONTAINS;
				$testTypeConstraint = TypeConstraint::createArrayLike(null, false, $this->typeConstraint);
				break;
			default:
				$oppositeOperator = QueryComparatorBuilder::oppositeOperator($operator);
				$testTypeConstraint = $this->typeConstraint;
			
		}
		
		if (!$testTypeConstraint->isPassableBy($columnComparable->getTypeConstraint($oppositeOperator))) {
			$arrayTypeConstraint = TypeConstraint::createArrayLike(null, false, $this->typeConstraint);
			throw new CriteriaConflictException('Incompatible comparison: ' 
					. $arrayTypeConstraint->__toString() . ' ' . $operator . ' ' 
					. $columnComparable->getTypeConstraint($oppositeOperator) );
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS) {
			$entityColumnComparable = $this->requestEntityColumnComparable();
			$queryComparator->match(
					$entityColumnComparable->buildQueryItem(CriteriaComparator::OPERATOR_EQUAL),
					QueryComparator::OPERATOR_EQUAL,
					$columnComparable->buildQueryItem(CriteriaComparator::OPERATOR_EQUAL));
			return;
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_NOT) {
			$queryComparator->match(
					$columnComparable->buildQueryItem(CriteriaComparator::OPERATOR_NOT_IN),
					QueryComparator::OPERATOR_NOT_IN, $this->requestToManyQueryItem());
			return;
		}
		
		
		$testQueryResult = $this->createTestQueryResult($columnComparable->buildQueryItem($oppositeOperator));
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_ANY) {
			$queryComparator->test(QueryComparator::OPERATOR_EXISTS, $testQueryResult);
			return;
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_NONE) {
			$queryComparator->test(QueryComparator::OPERATOR_NOT_EXISTS, $testQueryResult);
			return;
		}
	}
public function compareWith(QueryComparator $queryComparator, $operator, ComparisonStrategy $comparisonStrategy) {
		$this->validateOperator($operator);
		
		if ($comparisonStrategy->getType() != ComparisonStrategy::TYPE_COLUMN) {
			throw new CriteriaConflictException('Incompatible comparison');
		}
		
		$columnComparable = $comparisonStrategy->getColumnComparable();
		
		$oppositeOperator = null;
		$testTypeConstraint = null;
		switch ($operator) {
			case CriteriaComparator::OPERATOR_CONTAINS_ANY:
			case CriteriaComparator::OPERATOR_CONTAINS_NONE:
				$oppositeOperator = CriteriaComparator::OPERATOR_CONTAINS;
				$testTypeConstraint = TypeConstraint::createArrayLike(null, false, $this->typeConstraint);
				break;
			default:
				$oppositeOperator = QueryComparatorBuilder::oppositeOperator($operator);
				$testTypeConstraint = $this->typeConstraint;
			
		}
		
		if (!$testTypeConstraint->isPassableBy($columnComparable->getTypeConstraint($oppositeOperator))) {
			$arrayTypeConstraint = TypeConstraint::createArrayLike(null, false, $this->typeConstraint);
			throw new CriteriaConflictException('Incompatible comparison: ' 
					. $arrayTypeConstraint->__toString() . ' ' . $operator . ' ' 
					. $columnComparable->getTypeConstraint($oppositeOperator) );
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS) {
			$entityColumnComparable = $this->requestEntityColumnComparable();
			$queryComparator->match(
					$entityColumnComparable->buildQueryItem(CriteriaComparator::OPERATOR_EQUAL),
					QueryComparator::OPERATOR_EQUAL,
					$columnComparable->buildQueryItem(CriteriaComparator::OPERATOR_EQUAL));
			return;
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_NOT) {
			$queryComparator->match(
					$columnComparable->buildQueryItem(CriteriaComparator::OPERATOR_NOT_IN),
					QueryComparator::OPERATOR_NOT_IN, $this->requestToManyQueryItem());
			return;
		}
		
		
		$testQueryResult = $this->createTestQueryResult($columnComparable->buildQueryItem($oppositeOperator));
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_ANY) {
			$queryComparator->test(QueryComparator::OPERATOR_EXISTS, $testQueryResult);
			return;
		}
		
		if ($operator == CriteriaComparator::OPERATOR_CONTAINS_NONE) {
			$queryComparator->test(QueryComparator::OPERATOR_NOT_EXISTS, $testQueryResult);
			return;
		}
	}
/* (non-PHPdoc)
@see \n2n\persistence\orm\criteria\compare\CustomComparable::compareWith()