title: One-To-One, Unidirectional Relationship
body: <p>I have these entities: - Store and Package</p>
  
  <p>I'd like to build a StoreType form where i add package Id.</p>
  
  <p>I've made a StoreType Form class: (I would expect to get a select box from this, where all package are listed)</p>
  
  <p>I've add the package through one to one, but my problem is when i add package in store form then form is create but in my database store table column package are empty.i don't know why?</p>
  
  <p><li>Store.php</li></p>
  
  <pre><code>/**
   * @ORM\Entity
   */
  class Store
       {
          /**
           * @ORM\Id
           * @ORM\Column(type="integer")
           * @ORM\GeneratedValue(strategy="AUTO")
           */
          protected $id;
  
          /**
           * @ORM\Column(type="string", length="255")
           */
          protected $title;
  
          /**
           * @ORM\Column(type="string", length="255")
           */
          protected $domain;
  
          /**
           * @ORM\OneToOne(targetEntity="Package",cascade={"persist", "remove"})
           * @ORM\JoinColumn(name="package_id", referencedColumnName="id")
           */
          protected $package;
      }
  </code></pre>
  
  <p><li>Package.php</li></p>
  
  <pre><code>/**
   * @ORM\Entity
   */
  class Package
       {
           /**
            * @ORM\Id
            * @ORM\Column(type="integer")
            * @ORM\GeneratedValue(strategy="AUTO")
            */
           protected $id;
  
           /**
            * @ORM\Column(type="string", length=255)
            */
           protected $title;
  
           /**
            * @ORM\Column(type="text", length="4000")
            */
           protected $description;
  
           /**
            * @ORM\Column(type="boolean")
            */
           protected $active;
  
  
           public function __toString()
            {
             return $this-&gt;getTitle();
            }
       }
  </code></pre>
  
  <p><li>StoreType.php</li></p>
  
  <pre><code>class StoreType extends AbstractType
      {
          public function buildForm(FormBuilder $builder, array $options)
          {
              $builder
                  -&gt;add('title')
                  -&gt;add('domain')
                  -&gt;add('package','entity',array(
                      'class' =&gt; 'WebmuchProductBundle:Package',
              ));
          }
  
  
          public function getName()
          {
              return 'webmuch_productbundle_storetype';
          }
      }
  </code></pre>
  
  <p><li>StoreController.php</li></p>
  
  <pre><code>/**
   * Store controller.
   *
   * @Route("/store")
   */
  class StoreController extends Controller
  {
  /**
   * Lists all Store entities.
   *
   * @Route("/", name="store")
   * @Template()
   */
  public function indexAction()
  {
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
      $entities = $em-&gt;getRepository('WebmuchProductBundle:Store')-&gt;findAll();
  
      return array('entities' =&gt; $entities);
  }
  
  /**
   * Finds and displays a Store entity.
   *
   * @Route("/{id}/show", name="store_show")
   * @Template()
   */
  public function showAction($id)
  {
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
      $entity = $em-&gt;getRepository('WebmuchProductBundle:Store')-&gt;find($id);
  
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Store entity.');
      }
  
      $deleteForm = $this-&gt;createDeleteForm($id);
  
      return array(
          'entity'      =&gt; $entity,
          'delete_form' =&gt; $deleteForm-&gt;createView(),        );
  }
  
  /**
   * Displays a form to create a new Store entity.
   *
   * @Route("/new", name="store_new")
   * @Template()
   */
  public function newAction()
  {
      $store = new Store();
      $form   = $this-&gt;createForm(new StoreType(), $store);
  
      return array(
          'entity' =&gt; $store,
          'form'   =&gt; $form-&gt;createView()
      );
  }
  
  /**
   * Creates a new Store entity.
   *
   * @Route("/create", name="store_create")
   * @Method("post")
   * @Template("WebmuchProductBundle:Store:new.html.twig")
   */
  public function createAction()
  {
      $entity  = new Store();
      $request = $this-&gt;getRequest();
      $form    = $this-&gt;createForm(new StoreType(), $entity);
      $form-&gt;bindRequest($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          return $this-&gt;redirect($this-&gt;generateUrl('store_show', array('id' =&gt; $entity-&gt;getId())));
  
      }
  
      return array(
          'entity' =&gt; $entity,
          'form'   =&gt; $form-&gt;createView()
      );
  }
  
  /**
   * Displays a form to edit an existing Store entity.
   *
   * @Route("/{id}/edit", name="store_edit")
   * @Template()
   */
  public function editAction($id)
  {
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
      $entity = $em-&gt;getRepository('WebmuchProductBundle:Store')-&gt;find($id);
  
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Store entity.');
      }
  
      $editForm = $this-&gt;createForm(new StoreType(), $entity);
      $deleteForm = $this-&gt;createDeleteForm($id);
  
      return array(
          'entity'      =&gt; $entity,
          'edit_form'   =&gt; $editForm-&gt;createView(),
          'delete_form' =&gt; $deleteForm-&gt;createView(),
      );
  }
  
  /**
   * Edits an existing Store entity.
   *
   * @Route("/{id}/update", name="store_update")
   * @Method("post")
   * @Template("WebmuchProductBundle:Store:edit.html.twig")
   */
  public function updateAction($id)
  {
      $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
  
      $entity = $em-&gt;getRepository('WebmuchProductBundle:Store')-&gt;find($id);
  
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Store entity.');
      }
  
      $editForm   = $this-&gt;createForm(new StoreType(), $entity);
      $deleteForm = $this-&gt;createDeleteForm($id);
  
      $request = $this-&gt;getRequest();
  
      $editForm-&gt;bindRequest($request);
  
      if ($editForm-&gt;isValid()) {
          $em-&gt;persist($entity);
          $em-&gt;flush();
  
          return $this-&gt;redirect($this-&gt;generateUrl('store_edit', array('id' =&gt; $id)));
      }
  
      return array(
          'entity'      =&gt; $entity,
          'edit_form'   =&gt; $editForm-&gt;createView(),
          'delete_form' =&gt; $deleteForm-&gt;createView(),
      );
  }
  
  /**
   * Deletes a Store entity.
   *
   * @Route("/{id}/delete", name="store_delete")
   * @Method("post")
   */
  public function deleteAction($id)
  {
      $form = $this-&gt;createDeleteForm($id);
      $request = $this-&gt;getRequest();
  
      $form-&gt;bindRequest($request);
  
      if ($form-&gt;isValid()) {
          $em = $this-&gt;getDoctrine()-&gt;getEntityManager();
          $entity = $em-&gt;getRepository('WebmuchProductBundle:Store')-&gt;find($id);
  
          if (!$entity) {
              throw $this-&gt;createNotFoundException('Unable to find Store entity.');
          }
  
          $em-&gt;remove($entity);
          $em-&gt;flush();
      }
  
      return $this-&gt;redirect($this-&gt;generateUrl('store'));
  }
  
  private function createDeleteForm($id)
  {
      return $this-&gt;createFormBuilder(array('id' =&gt; $id))
          -&gt;add('id', 'hidden')
          -&gt;getForm()
      ;
  }
  }
  </code></pre>