title: An exception occurred while executing 'SELECT count(DISTINCT o0_.id) AS sclr_0 FROM Order o0_'
body: <p>When using SonataAdminBundle on Symfony 3.4.8 I had the following problem:</p>
  
  <p>When I go to view a list of my table, I get the following error.</p>
  
  <blockquote>
    <p>An exception occurred while executing 'SELECT count(DISTINCT o0_.id)
    AS sclr_0 FROM Order o0_':</p>
    
    <p>SQLSTATE[42000]: Syntax error or access violation: 1064 You have an
    error in your SQL syntax; check the manual that corresponds to your
    MySQL server version for the right syntax to use near 'Order o0_' at
    line 1</p>
  </blockquote>
  
  <p>My Entity\Order.php</p>
  
  <pre><code>&lt;?php
  
  namespace Gobusgo\GobusgoBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Order
   *
   * @ORM\Table(name="Order")
   *  @ORM\Entity(repositoryClass="Gobusgo\GobusgoBundle\Repository\OrderRepository")
   */
  class Order
  {
      /**
       * @var int
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      protected $id;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\User")
       */
      protected $userId;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Cargo")
       */
      protected $cargoId;
  
      /**
       * @var float
       *
       * @ORM\Column(type="float")
       */
      protected $price;
  
      /**
       * @var float
       *
       * @ORM\Column(name="quantity_of_cargo", type="float")
       */
      protected $quantityOfCargo;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $shippingAddress;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $deliveryAddress;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $additionalAddress1;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $additionalAddress2;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $additionalAddress3;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $additionalAddress4;
  
      /**
       * @ORM\ManyToOne(targetEntity="Gobusgo\GobusgoBundle\Entity\Address")
       *
       */
      protected $additionalAddress5;
  
      /**
       *
       *
       * @ORM\Column(type="datetime")
       */
      protected $dateOfOrder;
  
      /**
       * @var float
       *
       * @ORM\Column(type="float")
       */
      protected $status;
  
      /**
       * @return int
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * @param int $id
       */
      public function setId($id)
      {
          $this-&gt;id = $id;
      }
  
      /**
       * @return mixed
       */
      public function getUserId()
      {
          return $this-&gt;userId;
      }
  
      /**
       * @param mixed $userId
       */
      public function setUserId($userId)
      {
          $this-&gt;userId = $userId;
      }
  
      /**
       * @return mixed
       */
      public function getCargoId()
      {
          return $this-&gt;cargoId;
      }
  
      /**
       * @param mixed $cargoId
       */
      public function setCargoId($cargoId)
      {
          $this-&gt;cargoId = $cargoId;
      }
  
      /**
       * @return float
       */
      public function getPrice()
      {
          return $this-&gt;price;
      }
  
      /**
       * @param float $price
       */
      public function setPrice($price)
      {
          $this-&gt;price = $price;
      }
  
      /**
       * @return float
       */
      public function getQuantityOfCargo()
      {
          return $this-&gt;quantityOfCargo;
      }
  
      /**
       * @param float $quantityOfCargo
       */
      public function setQuantityOfCargo($quantityOfCargo)
      {
          $this-&gt;quantityOfCargo = $quantityOfCargo;
      }
  
      /**
       * @return mixed
       */
      public function getShippingAddress()
      {
          return $this-&gt;shippingAddress;
      }
  
      /**
       * @param mixed $shippingAddress
       */
      public function setShippingAddress($shippingAddress)
      {
          $this-&gt;shippingAddress = $shippingAddress;
      }
  
      /**
       * @return mixed
       */
      public function getDeliveryAddress()
      {
          return $this-&gt;deliveryAddress;
      }
  
      /**
       * @param mixed $deliveryAddress
       */
      public function setDeliveryAddress($deliveryAddress)
      {
          $this-&gt;deliveryAddress = $deliveryAddress;
      }
  
      /**
       * @return mixed
       */
      public function getAdditionalAddress1()
      {
          return $this-&gt;additionalAddress1;
      }
  
      /**
       * @param mixed $additionalAddress1
       */
      public function setAdditionalAddress1($additionalAddress1)
      {
          $this-&gt;additionalAddress1 = $additionalAddress1;
      }
  
      /**
       * @return mixed
       */
      public function getAdditionalAddress2()
      {
          return $this-&gt;additionalAddress2;
      }
  
      /**
       * @param mixed $additionalAddress2
       */
      public function setAdditionalAddress2($additionalAddress2)
      {
          $this-&gt;additionalAddress2 = $additionalAddress2;
      }
  
      /**
       * @return mixed
       */
      public function getAdditionalAddress3()
      {
          return $this-&gt;additionalAddress3;
      }
  
      /**
       * @param mixed $additionalAddress3
       */
      public function setAdditionalAddress3($additionalAddress3)
      {
          $this-&gt;additionalAddress3 = $additionalAddress3;
      }
  
      /**
       * @return mixed
       */
      public function getAdditionalAddress4()
      {
          return $this-&gt;additionalAddress4;
      }
  
      /**
       * @param mixed $additionalAddress4
       */
      public function setAdditionalAddress4($additionalAddress4)
      {
          $this-&gt;additionalAddress4 = $additionalAddress4;
      }
  
      /**
       * @return mixed
       */
      public function getAdditionalAddress5()
      {
          return $this-&gt;additionalAddress5;
      }
  
      /**
       * @param mixed $additionalAddress5
       */
      public function setAdditionalAddress5($additionalAddress5)
      {
          $this-&gt;additionalAddress5 = $additionalAddress5;
      }
  
      /**
       * @return mixed
       */
      public function getDateOfOrder()
      {
          return $this-&gt;dateOfOrder;
      }
  
      /**
       * @param mixed $dateOfOrder
       */
      public function setDateOfOrder($dateOfOrder)
      {
          $this-&gt;dateOfOrder = $dateOfOrder;
      }
  
      /**
       * @return float
       */
      public function getStatus()
      {
          return $this-&gt;status;
      }
  
      /**
       * @param float $status
       */
      public function setStatus($status)
      {
          $this-&gt;status = $status;
      }
  
  
  
  }
  </code></pre>
  
  <p>my Admin\OrderAdmin.php</p>
  
  <pre><code>&lt;?php
  
  namespace Gobusgo\GobusgoBundle\Admin;
  
  use Gobusgo\GobusgoBundle\Entity\Cargo;
  use Gobusgo\GobusgoBundle\Entity\User;
  use Sonata\AdminBundle\Admin\AbstractAdmin;
  use Sonata\AdminBundle\Datagrid\ListMapper;
  use Sonata\AdminBundle\Datagrid\DatagridMapper;
  use Sonata\AdminBundle\Form\FormMapper;
  use Sonata\AdminBundle\Form\Type\ModelType;
  
  class OrderAdmin extends AbstractAdmin
  {
  
      protected $baseRouteName = 'order_admin';
      protected $baseRoutePattern = 'order_admin';
  
      protected function configureFormFields(FormMapper $formMapper)
      {
          $formMapper
              -&gt;add('userId', ModelType::class,[
                  'class'=&gt;User::class,
                  'property'=&gt;'fullName',
              ])
              -&gt;add('cargoId', ModelType::class, [
                  'class'=&gt;Cargo::class,
                  'property'=&gt;'name'
              ])
          ;
      }
  
      protected function configureDatagridFilters(DatagridMapper $datagridMapper)
      {
          $datagridMapper-&gt;add('id');
      }
  
      protected function configureListFields(ListMapper $listMapper)
      {
          $listMapper-&gt;addIdentifier('id');
      }
  }
  </code></pre>
  
  <p>My services.yml contains the following code</p>
  
  <pre><code>admin.order:
      class: Gobusgo\GobusgoBundle\Admin\OrderAdmin
      arguments: [~, Gobusgo\GobusgoBundle\Entity\Order, ~]
      tags:
          - { name: sonata.admin, manager_type: orm, label: Заказ , group: "app.admin.group.admin" }
      public: true
  </code></pre>
  
  <p>Please, help me...</p>