title: Gedmo Timestampable always updating reference when deserializing with JMS Serializer
body: <p>I have a one-to-one relationship in my Symfony2 Project where a <code>Question</code> has a reference to a <code>Video</code> - both have a <em>created</em> and <em>updated</em> <em>Gedmo\Timestampable</em> behaviour which is basically working as expected. But a little bit too much:</p>
  
  <p>When deserializing the <code>Question</code> with the attached <code>Video</code> (as ID only to avoid other changes in the <em>Video metadata</em>) the <code>Video</code> document <strong>always</strong> gets an update both on the <code>created</code> <strong>and</strong> the <code>updated</code> field. This doesn't seem right. I may understand why the updated field gets a new date - even if actually nothing has changed on the object itself, but why <em>created</em> ?</p>
  
  <p>This is my code (simplyfied):</p>
  
  <p>Class Question:</p>
  
  <pre><code>&lt;?php
  
  /**
   * Class Question
   *
   * @Serializer\AccessorOrder("alphabetical")
   * @MongoDB\Document(
   *   collection="Quiz",
   *   repositoryClass="MyNamespace\Bundle\QuizBundle\Repository\QuestionRepository",
   * )
   * @package MyNamespace\Bundle\QuizBundle\Document
   */
  class Question
  {
      /**
       * @var \MongoId
       * @MongoDB\Id(strategy="auto")
       * @Serializer\Type("string")
       * @Serializer\Groups({
       *   "quiz_admin_list",
       *   "quiz_admin_detail"
       * })
       */
      protected $id;
  
      /**
       * @var \DateTime
       *
       * @Assert\Date(
       *   message = "quiz:constraints.model.question.created.invalid"
       * )
       * @Serializer\Type("DateTime&lt;'U'&gt;")
       * @Serializer\Accessor(getter="getCreated", setter="setCreatedEmpty")
       * @Serializer\Groups({
       *   "quiz_admin_list",
       *   "quiz_admin_detail"
       * })
       * @Gedmo\Timestampable(on="create")
       * @MongoDB\Date
       */
      protected $created;
  
  
      /**
       * @var \DateTime
       *
       * @Assert\Date(
       *   message = "quiz:constraints.model.question.updated.invalid"
       * )
       * @Serializer\Type("DateTime&lt;'U'&gt;")
       * @Serializer\Accessor(getter="getUpdated", setter="setUpdatedEmpty")
       * @Serializer\Groups({
       *   "quiz_admin_list",
       *   "quiz_admin_detail"
       * })
       * @Gedmo\Timestampable(on="update")
       * @MongoDB\Date
       */
      protected $updated;
  
      /**
       * @var Video
       *
       * @Serializer\Type("MyNamespace\Bundle\CoreMediaAdminBundle\Document\Video")
       * @Serializer\Groups({
       *   "quiz_admin_list",
       *   "quiz_admin_detail"
       * })
       * @MongoDB\ReferenceOne(
       *   targetDocument="MyNamespace\Bundle\CoreMediaAdminBundle\Document\Video",
       *   cascade={"all"}
       * )
       */
      protected $answerVideo;
  
  }
  </code></pre>
  
  <p>Class Video:</p>
  
  <pre><code>&lt;?php
  
  /**
   * Class Video
   * @Serializer\AccessorOrder("alphabetical")
   * @MongoDB\Document(
   *   collection="CoreMediaAdminVideo",
   *   repositoryClass="MyNamespace\Bundle\CoreMediaAdminBundle\Repository\VideoRepository",
   * )
   * @Vich\Uploadable
   * @package MyNamespace\Bundle\CoreMediaAdminBundle\Document
   */
  class Video 
  {
  
      /**
       * @MongoDB\Id(strategy="auto")
       * @Serializer\Type("string")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       */
      protected $id;
  
      /**
       * @Vich\UploadableField(
       *   mapping = "core_media_admin_video",
       *   fileNameProperty = "fileName"
       * )
       * @Serializer\Exclude
       * @var File $file
       */
      protected $file;
  
      /**
       * @MongoDB\Field(type="string")
       * @Serializer\Type("string")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       */
      protected $mimeType;
  
      /**
       * @var String
       *
       * @Assert\NotBlank(
       *   message = "core.media.admin:constraints.model.base.title.not_blank"
       * )
       * @Serializer\Type("string")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       * @MongoDB\Field(type="string")
       */
      protected $title;
  
      /**
       * @var \DateTime
       *
       * @Assert\Date(
       *   message = "core.media.admin:constraints.model.base.date.invalid"
       * )
       * @Serializer\Type("DateTime&lt;'U'&gt;")
       * @Serializer\Accessor(getter="getCreated", setter="setCreatedEmpty")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       * @Gedmo\Timestampable(on="create")
       * @MongoDB\Date
       */
      protected $created;
  
      /**
       * @var \DateTime
       *
       * @Assert\Date(
       *   message = "core.media.admin:constraints.model.base.date.invalid"
       * )
       * @Serializer\Type("DateTime&lt;'U'&gt;")
       * _Serializer\Accessor(getter="getUpdated", setter="setUpdatedEmpty")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       * @Gedmo\Timestampable(on="update")
       * @MongoDB\Date
       */
      protected $updated;
  
      /**
       * @var \DateTime
       *
       * @Assert\Date(
       *   message = "core.media.admin:constraints.model.base.date.invalid"
       * )
       * @Serializer\Type("DateTime&lt;'U'&gt;")
       * @Serializer\Groups({
       *   "core_media_list",
       *   "core_media_search",
       *   "core_media_video_list",
       *   "core_media_video_detail"
       * })
       * @Gedmo\Timestampable(on="update", field={"title", "tags", "comment", "dataOrigin", "description", "videoMetaData", "mimeType", "fileName", "file" })
       * @MongoDB\Date
       */
      protected $updatedContent;
  
  }
  </code></pre>
  
  <p>The interesting thing is, no changes are made on <code>Video</code> objects during deserialization - there is <strong>only</strong> the update Query to set the <code>created</code> and <code>updated</code> fields of the Video.. I also tested the <em>field</em> parameter for Timestampable to force an update only when one of those fields get an update but this seems to be ignored completely.</p>
  
  <p>Here is also the JSON which is deserialized and the corresponding MongoDB queries:</p>
  
  <pre><code>{
    "id": "547f31e650e56f2c26000063",
    "question_id": 12,
    "question_text": "Wer einen Gemüsegarten hat, sollte wissen, dass Schnecken…?",
    "answer_text": "test",
    "answer_video": {
      "id": "547f31d850e56f2c26000031"
    },
    "tags": [
      "Schnecken",
      "Basilikum",
      "Thymian",
      "Garten"
    ]
  }
  </code></pre>
  
  <p>Queries:</p>
  
  <pre><code>db.QuizQuestion.find({
    "_id": ObjectId("547f31e650e56f2c26000063")
  }).limit(1).limit();
  
  db.CoreMediaAdminVideo.update({
    "_id": ObjectId("547f31d850e56f2c26000031")
  },
  {
    "$set": {
      "created": newISODate("2014-12-03T21:30:02+01:00"),
      "updated": newISODate("2014-12-03T21:30:02+01:00"),
      "updatedContent": newISODate("2014-12-03T21:30:02+01:00")
    }
  });
  
  db.ARDBuffetQuizQuestion.update({
    "_id": ObjectId("547f31e650e56f2c26000063")
  },
  {
    "$set": {
      "created": newISODate("2014-12-03T21:30:02+01:00"),
      "updated": newISODate("2014-12-03T21:30:02+01:00"),
      "questionText": "Wer einen Gemüsegarten hat, sollte wissen, dass Schnecken…?",
      "answerText": "test",
      "answerVideo": {
        "$ref": "CoreMediaAdminVideo",
        "$id": ObjectId("547f31d850e56f2c26000031"),
        "$db": "my-database"
      }
    }
  });
  
  db.ARDBuffetQuizQuestion.update({
    "_id": ObjectId("547f31e650e56f2c26000063")
  },
  {
    "$set": {
      "tags": [
        {
          "value": "Schnecken",
          "normalized": "schnecken"
        },
        {
          "value": "Basilikum",
          "normalized": "basilikum"
        },
        {
          "value": "Thymian",
          "normalized": "thymian"
        },
        {
          "value": "Garten",
          "normalized": "garten"
        }
      ]
    }
  });
  
  db.ARDBuffetQuizQuestion.find({
    "_id": ObjectId("547f31e650e56f2c26000063")
  }).limit(1).limit();
  
  db.CoreMediaAdminVideo.find({
    "_id": ObjectId("547f31d850e56f2c26000031")
  }).limit(1).limit();
  </code></pre>