title: Force hibernate to eagerly load multiple associations without changing mapping
body: <p>I have a few entities with lazy one to many relationships (logic omitted for brevity):</p>
  
  <pre><code>@Entity
  class A{
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinColumn(name = "a_pk", nullable = false)
      List&lt;B&gt; blist = new ArrayList&lt;&gt;();
  
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinColumn(name = "a_pk", nullable = false)
      List&lt;C&gt; clist = new ArrayList&lt;&gt;();
  
      @Column(name = "natural_identifier", nullable = false)
      private String id;
  }
  
  @Entity
  class B{
  }
  
  @Entity
  class C{
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinColumn(name = "c_pk", nullable = false)
      List&lt;D&gt; dlist = new ArrayList&lt;&gt;();
  
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinColumn(name = "c_pk", nullable = false)
      List&lt;E&gt; elist = new ArrayList&lt;&gt;();
  }
  
  @Entity
  class D{
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinColumn(name = "d_pk", nullable = false)
      List&lt;F&gt; flist = new ArrayList&lt;&gt;();
  }
  
  @Entity
  class E{
  }
  
  @Entity
  class F{
  }
  </code></pre>
  
  <p>In some (very rare) case I want to load an instance of A and all of its associations eagerly. The reason for that is that I want to make some modifications on that A instance and it's children as a whole, and then either save or discard them, depending on user input. </p>
  
  <p>If I were to load things as they are needed, I'd have to reattach entities to a new session on user request, but they are being modified, and modifications should not be persisted yet.</p>
  
  <p>So I write something like that:</p>
  
  <pre><code>Session session = sessionFactory.openSession();
  s.beginTransaction();
  Criteria c = session
                      .createCriteria(A.class)
                      .add(Restrictions.eq("id", someValue))
                      .setFetchMode("blist", SELECT)
                      .setFetchMode("clist", SELECT)
                      .createAlias("clist", "c")
                      .setFetchMode("c.dlist", SELECT)
                      .setFetchMode("c.elist", SELECT)
                      .createAlias("c.dlist", "d")
                      .setFetchMode("d.flist", SELECT);
  A a = (A) c.uniqueResult();
  session.close(); // line 150
  
  a.getBlist().size(); // line 152 - debug
  a.getClist().size(); // line 153 - debug
  </code></pre>
  
  <p>When I try to access stuff I get an exception on <code>line 152</code>:</p>
  
  <pre><code>org.hibernate.LazyInitializationException:
  failed to lazily initialize a collection of role: 
  A.blist, could not initialize proxy - no Session
  </code></pre>
  
  <p>If I change fetch strategy to <code>JOIN</code> everywhere in the criteria, I get the same exception, but on <code>line 153</code> (in other words, the first association gets loaded, but not the others).</p>
  
  <p><em>EDIT: Alexey Malev suggested that fetch mode is set for an alias; it does seem to be true. With a following criteria:</em></p>
  
  <pre><code>Criteria c = session
                      .createCriteria(A.class)
                      .add(Restrictions.eq("id", someValue))
                      .setFetchMode("blist", JOIN)
                      .setFetchMode("clist", JOIN);
  </code></pre>
  
  <p><em>I'm getting a different Exception:</em> <code>org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags</code> <em>on line 149. So, join-fetching is not an option.</em></p>
  
  <p>The question is, how do I load the whole thing?</p>
  
  <p>Hibernate version 4.2.12.Final</p>