public function walkOrderByItem($orderByItem) { $sql = parent::walkOrderByItem($orderByItem); $hint = $this->getQuery()->getHint('sortableNulls.fields'); $expr = $orderByItem->expression; $type = strtoupper($orderByItem->type); if (is_array($hint) && count($hint)) { // check for a state field if ($expr instanceof Query\AST\PathExpression && $expr->type == Query\AST\PathExpression::TYPE_STATE_FIELD) { $fieldName = $expr->field; $dqlAlias = $expr->identificationVariable . (!empty($parts) ? '.' . implode('.', $parts) : ''); $search = $this->walkPathExpression($expr) . ' ' . $type; $index = $dqlAlias . '.' . $fieldName; $sql = str_replace($search, $search . ' ' . $hint[$index], $sql); } } return $sql; }