title: How to explicitly load a LAZY fetching member of a hibernate Entity
body: <p>Due to performance concern I have make most of the relation mapping in hibernate as <code>fetch = fetchType.LAZY</code> to avoid unnecessary query to the db.
  　</p>
  
  <pre><code>....
  private ConsumerEntity consumerEntity;
  
  @ManyToOne(fetchType.LAZY)
  @JoinColumn(name="orderId", insertable=false, updateable=false)
  public ConsumerEntity getConsumerEntity(){
      return this.consumerEntity;
  }
  ....
  </code></pre>
  
  <p>Above shows the mapping setting of relation for <code>OrderEntity</code> and <code>ConsumerEntity</code>.</p>
  
  <p>Each time the callers do a query, I will open a session, process the query and return them the result, then close the session.</p>
  
  <pre><code>Public OrderEntity getOrderEntity(orderQueryParam){
     Sting hql = buildHqlStrFromParam(orderQueryParam);
     return (OrderEntity)this.getEntityByHql(hql); // in the method just 1. open a session; 2. retrieve entity 3. close the session;
  }
  </code></pre>
  
  <p>But <strong>sometimes</strong> I know caller may need the related records as well. Like, if he ask about a specific Order record, I may want to give him the consumerEntity as well, so He can just do a <em>dot</em> thing to get the information he needed, and won't have to process a second query or get a lazy-loading-exception because the session has been closed:</p>
  
  <pre><code>  ...
    OrderEntity order = TradeService.getOrderEntity(orderQueryParam);
    ConsumerEntity consumer = order.getConsumerEntity();
    ....
  </code></pre>
  
  <p>But the scenario is very rare so that I don't want to change the <code>fetchType</code> to <code>EAGER</code>.</p>
  
  <p>How to do this? I mean I want to have a choose whether or not loaded the <code>ConsumerEntity</code> which was configured as <code>fetchType.LAZY</code>.</p>