title: Symfony2 Doctrine Unrecognized field:
body: <p>I've created an Entity to store some data i'm pulling via an api</p>
  
  <p>When i try to findByOne to see if the entry already exists, i get an error saying the field is not recognised.</p>
  
  <p>I've done a php app/console doctrine:schema:update --force
  I can see the table in my mySQL manager with the right fieldname 'StadiumID'
  So why cant doctrine find it when i do <code>findByOne();</code>
  My Entity Class:</p>
  
  <pre><code>&lt;?php
  
  namespace FantasyPro\DataBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Stadium
   *
   * @ORM\Table("fp_stadium")
   * @ORM\Entity(repositoryClass="FantasyPro\DataBundle\Entity\StadiumRepository")
   */
  class Stadium
  {
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="StadiumID", type="integer", length=2, nullable=false, unique=true)
       */
      private $stadiumID;
  
      /**
       * @var string
       *
       * @ORM\Column(name="Name", type="string", length=100, nullable=false)
       */
      private $name;
  
      /**
       * @var string
       *
       * @ORM\Column(name="City", type="string", length=50, nullable=false)
       */
      private $city;
  
      /**
       * @var string
       *
       * @ORM\Column(name="State", type="string", length=10, nullable=true)
       */
      private $state;
  
      /**
       * @var string
       *
       * @ORM\Column(name="Country", type="string", length=2, nullable=false)
       */
      private $country;
  
      /**
       * @var integer
       *
       * @ORM\Column(name="Capacity", type="integer", length=32, nullable=true)
       */
      private $capacity;
  
      /**
       * @var string
       *
       * @ORM\Column(name="PlayingSurface", type="string", length=50, nullable=true)
       */
      private $playingSurface;
  
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set stadiumID
       *
       * @param integer $stadiumID
       * @return Stadium
       */
      public function setStadiumID($stadiumID)
      {
          $this-&gt;stadiumID = $stadiumID;
  
          return $this;
      }
  
      /**
       * Get stadiumID
       *
       * @return integer 
       */
      public function getStadiumID()
      {
          return $this-&gt;stadiumID;
      }
  
      /**
       * Set name
       *
       * @param string $name
       * @return Stadium
       */
      public function setName($name)
      {
          $this-&gt;name = $name;
  
          return $this;
      }
  
      /**
       * Get name
       *
       * @return string 
       */
      public function getName()
      {
          return $this-&gt;name;
      }
  
      /**
       * Set city
       *
       * @param string $city
       * @return Stadium
       */
      public function setCity($city)
      {
          $this-&gt;city = $city;
  
          return $this;
      }
  
      /**
       * Get city
       *
       * @return string 
       */
      public function getCity()
      {
          return $this-&gt;city;
      }
  
      /**
       * Set state
       *
       * @param string $state
       * @return Stadium
       */
      public function setState($state)
      {
          $this-&gt;state = $state;
  
          return $this;
      }
  
      /**
       * Get state
       *
       * @return string 
       */
      public function getState()
      {
          return $this-&gt;state;
      }
  
      /**
       * Set country
       *
       * @param string $country
       * @return Stadium
       */
      public function setCountry($country)
      {
          $this-&gt;country = $country;
  
          return $this;
      }
  
      /**
       * Get country
       *
       * @return string 
       */
      public function getCountry()
      {
          return $this-&gt;country;
      }
  
      /**
       * Set capacity
       *
       * @param integer $capacity
       * @return Stadium
       */
      public function setCapacity($capacity)
      {
          $this-&gt;capacity = $capacity;
  
          return $this;
      }
  
      /**
       * Get capacity
       *
       * @return integer 
       */
      public function getCapacity()
      {
          return $this-&gt;capacity;
      }
  
      /**
       * Set playingSurface
       *
       * @param string $playingSurface
       * @return Stadium
       */
      public function setPlayingSurface($playingSurface)
      {
          $this-&gt;playingSurface = $playingSurface;
  
          return $this;
      }
  
      /**
       * Get playingSurface
       *
       * @return string 
       */
      public function getPlayingSurface()
      {
          return $this-&gt;playingSurface;
      }
  }
  </code></pre>
  
  <p>The code i'm using to add the data if it does not exist and to update it if it does exist:</p>
  
  <pre><code>&lt;?php
  
  namespace FantasyPro\DataBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use FantasyPro\DataBundle\Entity\Stadium;
  
  class DefaultController extends Controller
  {
      public function indexAction($name)
      {
          return $this-&gt;render('DataBundle:Default:index.html.twig', array('name' =&gt; $name));
      }
  
      public function updateStadiumAction(){
          //get list of stadiums
          $client = $this-&gt;container-&gt;get('fantasyapi');
          $stadiumData = $client-&gt;Stadiums();
          //var_dump($stadiumData);
          //get the entity manager
          $em = $this-&gt;getDoctrine()-&gt;getManager();
          $repo = $em-&gt;getRepository('DataBundle:Stadium');
          $log = $stadiumData;
  
          foreach($stadiumData as $stadium){
              // Get the current stadium in the list
              $criteria = array("StadiumID" =&gt;$stadium['StadiumID']);
             var_dump($criteria);
              $storedStadium = $repo-&gt;FindOneBy($criteria);
  
              if (!$storedStadium) {
                 /* throw $this-&gt;createNotFoundException(
                      'No product found for id '.$stadium['StadiumID']
                  );*/
                  //no stadium exists with the StadiumID passed
                  //create a new entry
                  $entry = new Stadium();
                  $entry-&gt;setStadiumID($stadium['StadiumID']);
                  $entry-&gt;setName($stadium['Name']);
                  $entry-&gt;setCity($stadium['City']);
                  $entry-&gt;setState($stadium['State']);
                  $entry-&gt;setCountry($stadium['Country']);
                  $entry-&gt;setCapacity($stadium['Capacity']);
                  $entry-&gt;setPlayingSurface($stadium['PlayingSurface']);
                  $em-&gt;persist($entry);
                  $log .= 'Added New Stadium: '.$stadium['StadiumID'].' : '.$stadium['Name'].'&lt;br&gt;';
              }else{
                  $storedStadium-&gt;setStadiumID($stadium['StadiumID']);
                  $storedStadium-&gt;setName($stadium['Name']);
                  $storedStadium-&gt;setCity($stadium['City']);
                  $storedStadium-&gt;setState($stadium['State']);
                  $storedStadium-&gt;setCountry($stadium['Country']);
                  $storedStadium-&gt;setCapacity($stadium['Capacity']);
                  $storedStadium-&gt;setPlayingSurface($stadium['PlayingSurface']);
                  $em-&gt;persist($storedStadium);
                  $log .= 'Updated Stadium: '.$stadium['StadiumID'].' : '.$stadium['Name'].'&lt;br&gt;';
              }
          }
          //$em-&gt;flush();
          return $this-&gt;render('DataBundle:Default:index.html.twig', array('log' =&gt; $log));
      }
  }
  </code></pre>