public function setSortableColumns($columns = array())
    {
        $repository = $this->get('orm.em')->getRepository($this->getEntityClass());

        foreach ($columns as $column => $options) {
            $sortMethodName = 'getQueryBuilderOrderedBy'.ucfirst(strtolower($column));
            if (method_exists($repository, $sortMethodName)) {
                $columns[$column]['sortable'] = true;
                continue;
            }
            if (property_exists($this->getEntityClass(), $column)) {
                // OneToMany and ManyToMany relations are not sortable
                $reader = new \Doctrine\Common\Annotations\AnnotationReader();
                $reflProperty = new \ReflectionProperty($this->getEntityClass(), $column);
                $OneToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\OneToMany');
                $ManyToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\ManyToMany');
                if (!$OneToMany && !$ManyToMany) {
                    $columns[$column]['sortable'] = true;
                    continue;
                }
            }
            $columns[$column]['sortable'] = false;
        }

        return $columns;
    }