title: org.hibernate.LazyInitializationException: could not initialize proxy - no Session, encore un fois
body: <p>Foo looks has this in it :</p>
  
  <pre><code>@ManyToMany
  private Set&lt;User&gt; favouritedBy;
  </code></pre>
  
  <p>while user has this:</p>
  
  <pre><code>@ManyToMany(mappedBy = "favouritedBy")
  private Set&lt;Foo&gt; favourites  = new HashSet&lt;Foo&gt;();
  public Set&lt;Foo&gt; getFavourites() {
    return favourite;
  }
  </code></pre>
  
  <p>And fooService has this, with the lazyloaded collection being accessed while session is opened, via the tranactional method :</p>
  
  <pre><code>@Transactional(readOnly = true)
  public Set&lt;Foo&gt; getFavourites(User user) {
  user = dao.get(User.class, user.getId()); //the dao gets a session
  Set&lt;Foo&gt; favourites = user.getFavourites();//but the session is not here and the exception is thrown?
  return  favourties;
  }
  </code></pre>
  
  <p><strong>EDIT</strong>
  This fixes it, without using criteria :</p>
  
  <pre><code>Set&lt;Foo&gt; favourites = new HashSet&lt;Foo&gt;(user.getFavourites());
  </code></pre>
  
  <p>and this fixes it with criteria</p>
  
  <pre><code>Session session = sessionFactory.getCurrentSession();
  final Criteria crit = session.createCriteria(Foo.class);
  crit.setFetchMode("favourites", FetchMode.JOIN);
  crit.add(Property.forName("id").eq(id));
  return (Foo) crit.uniqueResult();
  </code></pre>