title: Doctrine2 entity , tell not update certain columns
body: <p>I don't want to update certain columns for the table.</p>
  
  <p>In the Questions table, I just want to update the question column:</p>
  
  <pre><code>question:
  
  id
  question
  created_by
  created_at
  modified_by
  modified_at
  is_Active
  </code></pre>
  
  <p>In the above table column, I don't need to update the <code>create_at</code>, <code>created_by</code>, <code>modified_by</code>, <code>modified_at</code>, is_active columns. This is the entity I am using.</p>
  
  <p><strong>Entity:</strong></p>
  
  <pre><code>    &lt;?php
  
      namespace Library\Entity;
  
      use Doctrine\ORM\Mapping as ORM;
  
      /**
       * Base class for all the Entities
       * This class maps id, active, created and modified columns 
       *
       * @author 
  
   */
  /**
   * @ORM\MappedSuperclass
   */
  class BaseEntity {
  
      /**
       * @ORM\Id
       * @ORM\GeneratedValue
       * @ORM\Column(name="id", type="integer")
       * @var integer
       */
      protected $id;
  
      /**
       * @ORM\Column(name="is_active", type="boolean")
       * @var boolean
       */
      protected $active;
  
      /**
       * @ORM\Column(name="created_at", type="datetime")
       * @var datetime
       */
      protected $createdAt;
  
      /**
       * @ORM\Column(name="created_by", type="integer", nullable=true)
       * @var integer
       */
      protected $createdBy;
  
      /**
       * @ORM\Column(name="modified_at", type="datetime")
       * @var datetime
       */
      protected $modifiedAt;
  
      /**
       * @ORM\Column(name="modified_by", type="integer")
       * @var integer
       */
      protected $modifiedBy;
  
      public function getId() {
          return $this-&gt;id;
      }
  
      public function getActive() {
          return $this-&gt;active;
      }
  
      public function getCreatedAt() {
          return $this-&gt;createdAt;
      }
  
      public function getCreatedBy() {
          return $this-&gt;createdBy;
      }
  
      public function getModifiedAt() {
          return $this-&gt;modifiedAt;
      }
  
      public function getModifiedBy() {
          return $this-&gt;modifiedBy;
      }
  
      public function setId($id) {
          $this-&gt;id = $id;
      }
  
      public function setActive($active) {
          $this-&gt;active = $active;
      }
  
      public function setCreatedAt($createdAt) {
          $this-&gt;createdAt = $createdAt;
      }
  
      public function setCreatedBy($createdBy) {
          $this-&gt;createdBy = $createdBy;
      }
  
      public function setModifiedAt($modifiedAt) {
          $this-&gt;modifiedAt = $modifiedAt;
      }
  
      public function setModifiedBy($modifiedBy) {
          $this-&gt;modifiedBy = $modifiedBy;
      }
  }
  </code></pre>
  
  <p><strong>This is my <code>Question</code> Entity:</strong></p>
  
  <pre><code>&lt;?php
  
  namespace Survey\Entity;
  
  use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\ORM\Mapping as ORM;
  use Library\Entity\BaseEntity;
  use Survey\Entity\Survey;
  
  /**
   * Description of Survey Questions
   *
   * @author Mubarak
   */
  
  /**
   * @ORM\Entity
   * @ORM\Table(name="survey_questions")
   */
  
  class Question extends BaseEntity{
  
      /**
       * @ORM\Column(name="question", type="string")
       * @var string
       */
      protected $question;
  
      /**
       * @ORM\ManyToOne(targetEntity="Survey\Entity\Survey", inversedBy="questions")
       * @ORM\JoinColumn(name="survey_id", referencedColumnName="id")
       */
      private $surveys;
  
      public function getQuestion() {
          return $this-&gt;question;
      }
  
      public function setQuestion($question) {
          $this-&gt;question = $question;
      }
  
      public function getSurveys() {
          return $this-&gt;surveys;
      }
  
  //    public function setSurveys(ArrayCollection $survey) {
      public function setSurveys(Survey $surveys = null) {
          $this-&gt;surveys = $surveys;
      }
  
  //    public function __toString() {
  //        return __CLASS__ . ": [id: {$this-&gt;id}, name: {$this-&gt;name}]";
  //    }
  }
  </code></pre>
  
  <p>Here is my update function:</p>
  
  <pre><code>public function updateQuestion($userId, $data ) {
          try{
              $surveyId = 1;
              $survey = $this-&gt;entityManager-&gt;getRepository('Survey\Entity\Survey')-&gt;find($surveyId);
              $question = new Question();
              $question-&gt;setQuestion($data['question']);
              $question-&gt;setSurveys($survey);
              $question-&gt;setId(1);
              $this-&gt;entityManager-&gt;merge($question);
              $this-&gt;entityManager-&gt;flush();
          } catch (Exception $ex) {
              throw new Exception("Couldnt update the Question");
          }
  </code></pre>
  
  <p>Below is my error message i am getting:</p>
  
  <blockquote>
    <p>An exception occurred while executing 'UPDATE survey_questions SET is_active = ?, created_at = ?, created_by = ?, modified_at = ?, modified_by = ? WHERE id = ?' with params [null, null, null, null, null, 1]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1048 Column 'created_at' cannot be null</p>
  </blockquote>
  
  <p>Here is my insert Operation:</p>
  
  <pre><code>public function insertQuestion($userId, $survey, $questionArr) {
          try{
              $question = new Question();
              $question-&gt;setQuestion($questionArr['question']);
              $question-&gt;setSurveys($survey);
              $question-&gt;setActive(1);
              $question-&gt;setCreatedBy($userId);
              $question-&gt;setCreatedAt($this-&gt;createdAt);
              $question-&gt;setModifiedBy($userId);
              $question-&gt;setModifiedAt($this-&gt;modifiedAt);
              $this-&gt;entityManager-&gt;persist($question);
              $this-&gt;entityManager-&gt;flush();
              return $question;
          }catch(Exception $ex){
             throw new Exception("Couldnt insert the question");
          }
      }
  </code></pre>