public static function down(DAOConnected $object, LogicalObject $exp = null) { $getMethod = 'get' . ucfirst(self::$property); Assert::isTrue(method_exists($object, $getMethod)); $oldPosition = $object->{$getMethod}(); $criteria = Criteria::create($object->dao())->add(Expression::gt(self::$property, $oldPosition))->addOrder(OrderBy::create(self::$property)->asc())->setLimit(1); if ($exp) { $criteria->add($exp); } if ($lowerObject = $criteria->get()) { DaoUtils::setNullValue(self::$nullValue); DaoUtils::swap($lowerObject, $object, self::$property); } }
private function loadNextChunk($id) { Assert::isNotNull($this->dao); $this->offset = 0; $criteria = Criteria::create($this->dao); if ($this->projection) { $criteria->setProjection($this->projection); } $criteria->addOrder($this->keyProperty)->setLimit($this->chunkSize); if ($id !== null) { $criteria->add(Expression::gt($this->keyProperty, $id)); } // preserving memory bloat $this->dao->dropIdentityMap(); $this->chunk = $criteria->getList(); return $this->chunk; }