title: Convert Hibernate entity to json using JSONArray.fromObject
body: <p>I am having a problem converting data to json.</p>
  
  <pre><code>Session session = sessionFactory.openSession();       
  Affiliate affiliate = (affiliate) session.get( Affiliate , pk );
  session.close();
  JSONArray.fromObject(affiliate);
  </code></pre>
  
  <p>the debugger showing that the row was fetched.<br>
  but i get this exception when trying to convert to json string:</p>
  
  <pre><code>Exception in thread "main" net.sf.json.JSONException: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.affiliates.hibernate.Affiliate.employees, no session or session was closed
  at net.sf.json.JSONObject._fromBean(JSONObject.java:959)    ...
  </code></pre>
  
  <p>this is my Affiliate Entity</p>
  
  <pre><code>    @Entity(name="AFFILIATE")
      @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
      public class Affiliate extends HibernateBean{ 
  
          @Id
          @GeneratedValue(strategy=GenerationType.IDENTITY) 
          @Column(name="AFFILIATE_ID")
          private long id;
  
          @ManyToOne(targetEntity = Affiliate.class)
          @JoinColumn(name="PARENT_ID")
          private Affiliate parent;
  
  
  
          @ManyToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY)
          @JoinTable(name="EMPLOYEES_AFFILIATES"  , joinColumns = {@JoinColumn(name="AFFILIATE_ID")},inverseJoinColumns={@JoinColumn(name="EMPLOYEE_ID")})
          private Set&lt;Employee&gt; employees = new HashSet&lt;Employee&gt;(0);
  
   getters and setters...
  
      }
  </code></pre>
  
  <p>Thanks</p>