title: Getting associated entries in Doctrine 2
body: <p>I've decided that it would be a good asset to get familiar with an ORM and went for Doctrine 2 as the ORM of choice.</p>
  
  <p>I'm working on a test project to learn the basics of Doctrine. Although most people usually go with a blog, I've decided to make a basic app in which you can save and track orders. My database schema would be as follows:</p>
  
  <pre><code>User
      id
      name
  Product
      id
      name
      price
  Sales_order
      id
      user_id
      product_id
      quantity
      unit_price
  </code></pre>
  
  <p>Hence, my Order model looks like:</p>
  
  <pre><code>/**
   * @Entity
   * @Table(name="sales_order")
   */
  class Order {
  
      /**
       * @Id
       * @Column(type="integer", nullable=false)
       * @GeneratedValue(strategy="AUTO")
       */
      private $Id;
  
      /**
       * @OneToOne(targetEntity="User", inversedBy="user")
       */
      private $user;
  
      /**
       * @OneToOne(targetEntity="Product", inversedBy="product")
       */
      private $product;
  
      /**
       * @Column(type="integer", nullable=false)
       */
      private $quantity;
  }
  </code></pre>
  
  <p>Now, the question is, is there a simple way of accessing all the orders from the user model? Should I write DQL (doctrine query language) for these kind of basic stuff or is there a way to easily get associated entities? I mean, there wouldn't be any point to this otherwise, right? Also, am I doing these associations correctly? I'm really confused in this very basic model... Detailed help is really appreciated. Thank you.</p>