/**
  * @return SelectQuery
  **/
 protected function joinHelperTable(SelectQuery $query)
 {
     $uc = $this->container;
     if (!$query->hasJoinedTable($uc->getHelperTable())) {
         $query->join($uc->getHelperTable(), Expression::eq(new DBField($uc->getParentTableIdField(), $uc->getDao()->getTable()), new DBField($uc->getChildIdField(), $uc->getHelperTable())));
     }
     return $query->andWhere(Expression::eq(new DBField($uc->getParentIdField(), $uc->getHelperTable()), new DBValue($uc->getParentObject()->getId())));
 }
 /**
  * @return SelectQuery
  **/
 protected function targetize(SelectQuery $query)
 {
     return $query->andWhere(Expression::eqId(new DBField($this->container->getParentIdField(), $this->container->getDao()->getTable()), $this->container->getParentObject()));
 }
 /**
  * @return SelectQuery
  **/
 public function fillSelectQuery(SelectQuery $query)
 {
     $query->limit($this->limit, $this->offset);
     if ($this->distinct) {
         $query->distinct();
     }
     if ($this->logic->getSize()) {
         $query->andWhere($this->logic->toMapped($this->checkAndGetDao(), $query));
     }
     if ($this->order) {
         $query->setOrderChain($this->order->toMapped($this->checkAndGetDao(), $query));
     }
     if ($this->projection->isEmpty() && $this->strategy->getId() != FetchStrategy::CASCADE) {
         $this->joinProperties($query, $this->checkAndGetDao(), $this->checkAndGetDao()->getTable(), true);
     }
     return $query;
 }