title: PHP Doctrine 2 ORM: Non-Entity object as attribute in entity
body: <p>I'm using <a href="http://www.doctrine-project.org" rel="nofollow">Doctrine ORM 2</a>.
  I got the following entity class.</p>
  
  <pre><code>/**
   * @Entity
   * @Table(name="objects")
   */
  class MyObject
  {
    /**
     * @Id
     * @GeneratedValue
     * @Column(type="integer")
     */
    private $id;
  
    /**
     * @var Coordinate
     */
    private $coordinate;
  }
  
  class Coordinate
  {
     private $x;
     private $y;
     private $z;
  }
  </code></pre>
  
  <p>I want to implement the 3 coordinate values in a separate class for better handling within php. But within the database I want the 3 values to be included in the database table "objects".</p>
  
  <p>Does anyone know how to achieve this?</p>
  
  <p>Best regards</p>
  
  <p>Edit:
  I found a workaround but it's not the nicest.</p>
  
  <pre><code>    /**
       * 
   * @var integer 
   * @Column(type="integer")
   */
  private $x;
  /**
   * 
   * @var integer 
   * @Column(type="integer")
   */
  private $y;
  /**
   * 
   * @var integer 
   * @Column(type="integer")
   */
  private $z;
  
  public function getCoordinate()
  {
      return new Coordinate($this-&gt;x, $this-&gt;y, $this-&gt;z);
  }
  
  public function setCoordinate(Coordinate $coord)
  {
      $this-&gt;x = $coord-&gt;getX();
      $this-&gt;y = $coord-&gt;getY();
      $this-&gt;z = $coord-&gt;getZ();
  }
  </code></pre>