title: PHP/Symfony3/Doctrine association returns NULL
body: <p>I have 2 tables, one a GrowerProjection and one a Crop. One crop can have many grower projections associated with it. I came into this project with the underlying database already built, and in the database, Crop has a unique ID of, for instance, CROP-001, stored in a column called crop_ID. In the GrowerProjection table there is also a crop_ID field, which lets you see what crop a particular projection is talking about. </p>
  
  <p>So now I have used Doctrine to generate entities, and I am now trying to tie these entities together. When I try to make a ManyToOne association, I always get a null value back. My questions are: 1. What am I doing wrong and 2. How do I debug these kinds of issues in the future?</p>
  
  <p>I have tried validating the schema and updating the schema via the console, but that seemed to have no effect.</p>
  
  <p>Here is a relevant snip from Growerprojection's entity:</p>
  
  <pre><code>
  /**
   * Growerprojection
   *
   * @ORM\Table(name="growerProjection")
   * @ORM\Entity
   */
  class Growerprojection
  {
      /** 
       * @ORM\Id
       * @ORM\ManyToOne(targetEntity="Crop")
       * @ORM\JoinColumn(name="cropId", referencedColumnName="cropId")
       */
      private $crop;
  
      /**
       * @var string
       *
       * @ORM\Column(name="grower_ID", type="string", length=16, nullable=false)
       */
      private $growerId;
  
      /**
       * @var string
       *
       * @ORM\Column(name="crop_ID", type="string", length=16, nullable=false)
       */
      private $cropId;
  
      public function getReadyToLoadDt() {
          return $this->prjreadytoloaddt;
      }
  
      public function setReadyToLoadDt($theDate) {
          $this->prjreadytoloaddt=$theDate;
      }
  
      public function getCrop() {
          return $this->crop;
      }
  
  }
  </code></pre>
  
  <p>I have tried that with the join column as crop_ID and cropId, as doctrine uses cropId but the actual tables use crop_ID. I have tried with and without the @ID directive. No change. crop is always null. </p>
  
  <p>Here is the Crop entity part:</p>
  
  <pre><code>
  /**
   * Crop
   *
   * @ORM\Table(name="crop")
   * @ORM\Entity
   */
  class Crop
  {
      /**
       * @var string
       *
       * @ORM\Column(name="commodity_ID", type="string", length=16, nullable=false)
       */
      private $commodityId;
  
      /**
       * @var string
       *
       * @ORM\Column(name="crop_ID", type="string", length=16)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $cropId;
  
      public function getCommodityID() {
          return $this->commodityId;
      }
  }
  </code></pre>
  
  <p>Then, here is the controller's action:</p>
  
  <pre><code>
      public function testAction(Request $request)
      {
          $repository = $this->getDoctrine()->getRepository('AppBundle:Growerprojection');
          $projections = $repository->findBy(
              array('growerId' => 'GROW-001'),
              array('prjreadytoloaddt' => 'ASC')
              );
          $myCrop = $projections[0]->getCrop();
          \Doctrine\Common\Util\Debug::dump($myCrop);
          return $this->render('grower/growerTest.html.twig', 
              array('projections' => $projections));
      }
  </code></pre>
  
  <p>This finds a grower projection, that grower projection has CROP-001 as the cropId, and there is a crop in the crop table with the crop_ID of CROP-001. </p>
  
  <p>The line \Doctrine\Common\Util\Debug::dump($myCrop); will always produce NULL, and when I do a dump() inside the twig, I also see that the projection arrives and is populated, but the column crop is null.</p>
  
  <p>What am I doing wrong here, and how do I get this association to work, and how do I debug this in the future so I don't have to pester y'all about it?</p>