title: Doctrine2 ODM - Object ( or Embedded Document ) as _id
body: <p>I have a process running an incremental map reduce to a collection where I am looking at metrics over different time periods - grouping by id(s) and date.  So my output collection essentially has a composite id to handle the grouping.</p>
  
  <pre><code>{
      "_id" : {
          "site" : 67,
          "dt" : ISODate("2012-07-03T00:00:00Z")
      },
      "value" : {
          // Metrics here
      }
  }
  </code></pre>
  
  <p>I want to be able to fetch results from this collection in my Symfony2 app using the ODM - but having trouble with the <code>_id</code> field. I thought I might be able to specify it as an <code>@Id</code> and <code>@embedOne</code>:</p>
  
  <pre><code>   /**
      * @MongoDB\Id
      * @MongoDB\EmbedOne(targetDocument="reportId")
      */
     protected $id;
  </code></pre>
  
  <p>However, this doesn't work.  I also tried setting <code>@Id</code> with <code>strategy=NONE</code>, and I can use the QueryBuilder to fetch rows, but it errors when trying to hydrate my Document class. I tried slugging the site id and date ( <code>67-134137916</code> ) and it allows me to use the DocumentManager, but I lose the ability to query by date ranges.</p>
  
  <p>Anyone have any input on how to handle an object as an id in Doctrine2's ODM, is this supported?</p>
  
  <p><strong>edit:</strong>
  Removed composite primary key tag - question really pertains to using an object as a primary key.</p>