title: how to set auto increment id in doctrine2 odm in zf2?
body: <p>i used doctrine2 odm in zf2 and i want to make auto increment id,i make calendar id as auto increment but it does not save in database,how i make calendar id auto increment and save in database?
  here is my code:</p>
  
  <pre><code>&lt;?php
  namespace Calendar\Document;
  
  use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
  //use Doctrine\ODM\MongoDB\DocumentRepository;
  
  /** @ODM\Document(collection="calendar") */
   class Calendar
  {
  /** @ODM\Id */
  private $id;
  
  /** @ODM\Field(type="int",strategy="INCREMENT") */
  private $calendar_id;
  
  /** @ODM\Field(type="int") */
  private $user_id;
  
  /** @ODM\Field(type="string") */
  private $title;
  
  /** @ODM\Field(type="string") */
  private $description;
  
  /**
  * @return the table field
  */
  public function getProperty($property) {
      if (property_exists($this, $property)) {
        return $this-&gt;$property;
      }
  }
  
  public function setProperty($property, $value) {
      if (property_exists($this, $property)) {
        $this-&gt;$property = $value;
      }
      return $this;
  }
  
  public function getData(){
       return array(
           'id'=&gt;$this-&gt;id,
           'calendar_id'=&gt;calendar_id,
           'user_id'=&gt;$this-&gt;user_id,
           'title'=&gt;$this-&gt;title,
           'description'=&gt;$this-&gt;description    
       );
  }
  }
  </code></pre>
  
  <p>and here is my form:</p>
  
  <pre><code>&lt;?php
  namespace Calendar\Form;
  
  use Zend\Form\Form;
   class CalendarForm extends Form
  {
  public function __construct($name = null)
  {
      // we want to ignore the name passed
      parent::__construct('calendar');
      $this-&gt;setAttribute('method', 'post');
  
      $this-&gt;add(array(
          'name' =&gt; 'calendar_id',
          'attributes' =&gt; array(
              'type'  =&gt; 'hidden',
          ),
      ));
  
      $this-&gt;add(array(
          'name' =&gt; 'user_id',
          'attributes' =&gt; array(
              'type'  =&gt; 'hidden',
          ),
      ));
      $this-&gt;add(array(
          'name' =&gt; 'title',
          'attributes' =&gt; array(
              'type'  =&gt; 'text',
          ),
          'options' =&gt; array(
              'label' =&gt; 'Title',
          ),
      ));
      $this-&gt;add(array(
          'name' =&gt; 'description',
          'attributes' =&gt; array(
              'type'  =&gt; 'textarea',
          ),
          'options' =&gt; array(
              'label' =&gt; 'description',
          ),
      ));
      $this-&gt;add(array(
          'name' =&gt; 'submit',
          'attributes' =&gt; array(
              'type'  =&gt; 'submit',
              'value' =&gt; 'Save',
              'id' =&gt; 'submitbutton',
          ),
      ));
    }
   }
  </code></pre>
  
  <p>and here is my createaction code:</p>
  
  <pre><code> public function createAction()
      {
          $dm = $this-&gt;getServiceLocator()-&gt;get('doctrine.documentmanager.odm_default');
              $form = new CalendarForm();
              $update=false;
              $message='';
              if($this-&gt;getRequest()-&gt;isPost())
              {
                  $post = $this-&gt;getRequest()-&gt;getPost();
                  $form-&gt;setInputFilter($form-&gt;getInputFilter());
                  $form-&gt;setData($post);
                  if($form-&gt;isValid())
                  {
                      $formData=$form-&gt;getData();
                      $s = new Calendar();
                      $s-&gt;setProperty('calendar_id',$_post['calendar_id']);
                      $s-&gt;setProperty('user_id',1);
                      $s-&gt;setProperty('title',$post['title']);
                      $s-&gt;setProperty('description',$post['description']);
                      $dm-&gt;persist($s);
                      $dm-&gt;flush();
                      $update=1;
                      $message='calendar Added Successfully.';
                      //$form = new CalendarForm();
                      //$this-&gt;redirect()-&gt;toRoute('calendar');
                  }
              }
              return array( 'form' =&gt; $form, 'add_message' =&gt; $message, 'update' =&gt; $update, 'calendar'=&gt;$this-&gt;calendar );               
          }
  </code></pre>