/**
  * Adds a join for a has many relation to the statement
  * @param zibo\library\database\manipulation\expression\TableExpression $table
  * @param zibo\library\database\manipulation\expression\TableExpression $relationTable
  * @param zibo\library\database\manipulation\expression\TableExpression $linkTable
  * @param string $fieldName
  * @return null
  */
 private function addHasManyJoin(TableExpression $table, TableExpression $relationTable, TableExpression $linkTable, $fieldName)
 {
     $this->statement->setDistinct(true);
     $foreignKeyToSelf = $this->meta->getRelationForeignKeyToSelf($fieldName)->getName();
     $expressionPrimaryKey = new FieldExpression(ModelTable::PRIMARY_KEY, $table, self::ALIAS_SELF . self::ALIAS_SEPARATOR . ModelTable::PRIMARY_KEY);
     $expressionForeignKey = new FieldExpression($foreignKeyToSelf, $linkTable, $linkTable->getAlias() . self::ALIAS_SEPARATOR . $foreignKeyToSelf);
     $joinCondition = new SimpleCondition($expressionPrimaryKey, $expressionForeignKey, Condition::OPERATOR_EQUALS);
     $join = new JoinExpression(JoinExpression::TYPE_LEFT, $linkTable, $joinCondition);
     $this->tables[self::ALIAS_SELF]->addJoin($join);
     $foreignKey = $this->meta->getRelationForeignKey($fieldName)->getName();
     $expressionPrimaryKey = new FieldExpression(ModelTable::PRIMARY_KEY, $relationTable, $fieldName . self::ALIAS_SEPARATOR . ModelTable::PRIMARY_KEY);
     $expressionForeignKey = new FieldExpression($foreignKey, $linkTable, $linkTable->getAlias() . self::ALIAS_SEPARATOR . $foreignKey);
     $joinCondition = new SimpleCondition($expressionPrimaryKey, $expressionForeignKey, Condition::OPERATOR_EQUALS);
     $join = new JoinExpression(JoinExpression::TYPE_LEFT, $relationTable, $joinCondition);
     $this->tables[self::ALIAS_SELF]->addJoin($join);
 }