title: DDD: refer to an entity inside an aggregate root by its identity
body: <p>I'm stuck on finding the proper way to refer to <em>entities</em> located inside an <em>aggregate root</em>, when we only got their <em>identities</em> coming from URL parameters. I asked a <a href="https://stackoverflow.com/questions/7196820/update-an-entity-inside-an-aggregate">previous question</a> which ended up focused on <em>value objects</em>, so I'm starting with another example here.</p>
  
  <p>Let's say we want to modify an <code>OrderLine</code> inside an <code>Order</code>:</p>
  
  <ul>
  <li>The user goes to a page where he can see the Order summary along with all its Order Lines.</li>
  <li>The user clicks on the <strong>edit</strong> button next to an Order Line.</li>
  <li>He gets directed to <code>edit-order-line?orderId=x&amp;orderLineId=y</code></li>
  </ul>
  
  <p>Now if I need to update the quantity in the OrderLine, I can do:</p>
  
  <pre><code>Order order = orderRepository.find(orderId);
  order.updateQuantity(orderLineId, 2);
  </code></pre>
  
  <p>However, I don't feel very comfortable with the idea of leaving the responsibility to the Order to retrieve parts of itself by Id. My view on the subject is that within the domain, we should just <strong>talk with objects</strong>, and never with Ids. Ids are not part of the <em>ubiquitous language</em> and I believe they should live outside of the domain, for example in the Controller.</p>
  
  <p>I would feel more confident with something like:</p>
  
  <pre><code>Order order = orderRepository.find(orderId);
  OrderLine orderLine = em.find(OrderLine.class, orderLineId);
  order.updateQuantity(orderLine, 2);
  </code></pre>
  
  <p>Though I don't like the idea of interacting directly with an Entity Manager, either. I feel like I'm bypassing the Repository and Aggregate Root responsibilities (because I <em>could</em>, potentially, interact with the OrderLine directly).</p>
  
  <p>How do you work around that?</p>