title: Hibernate could not initialize proxy - no Session
body: <p>My code retrieves all information related to the user:</p>
  
  <pre><code>SessionFactory sessionFactory = HibernateUtilities.configureSessionFactory();
  Session session = sessionFactory.openSession();
  UserDetails ud = null;
  Set&lt;Address&gt; userAddress = null;
  
  try {
      session.beginTransaction();
      ud = (UserDetails) session.get(UserDetails.class, 1);
      userAddress = ud.getAddresses();
      session.getTransaction().commit();
  } catch (HibernateException e) {
      e.printStackTrace();
      session.getTransaction().rollback();
  } finally {
      session.close();
  }
  
  System.out.println(ud.getName());
  
  for(Address addr: userAddress){
      System.out.println("State " + addr.getState());
  }
  </code></pre>
  
  <p>The <code>ud.getAddresses()</code> simply returns a set of <code>Address</code>es of the user.</p>
  
  <p>My question is: why does the <code>ud</code> object still have its value (eg, name) even though the session is already closed? <code>getAddresses()</code> is an instance variable of the <code>UserDetails</code> class. But why can't I retrieve its value but I can retrieve regular instance variables of the <code>UserDetails</code> class?</p>
  
  <p><code>ud.getAddresses()</code> is an <code>@EmbeddedCollection</code>.</p>