title: EntityManager.merge() issues SELECT's on all entities in the object graph
body: <p>I'm using JPA 2 and Hibernate 3. I noticed that calling <code>EntityManager.merge()</code> causes a SELECT on every referenced entity in the object graph PLUS inner joins between some of them.</p>
  
  <p>Suppose you want to merge() a FooBar.</p>
  
  <pre><code>@Entity
  public class FooBar {
      @ManyToOne
      private Foo foo;
  
      @ManyToOne
      private Bar bar;
  }
  
  @Entity
  public class Foo {
      @ManyToOne
      private Baz baz;
  }
  
  @Entity
  public class Bar {
      @ManyToOne
      private Baz baz;
  }
  </code></pre>
  
  <p>If you do, Hibernate will issue a SELECT for each of FooBar, Foo, and Bar, and two for Baz. Then, it will issue a SELECT for Foo joined with Baz and another for Bar joined with Baz. Since I just wanted to merge a FooBar, I was expecting a single SELECT from it, but I ended up with a whopping 7 SELECT's!</p>
  
  <p>First of all, is this normal? Second, if it is, is there a way to issue just a single SELECT?</p>
  
  <p>Thanks.</p>