title: Regarding Hibernate LazyInitialization Error
body: <p>I am using <code>transactions</code> on <code>EJB2.0</code> layer and from there am making call to <code>DAO</code> layer wherein am making hibernate calls to db. </p>
  
  <p>Issue am having right now is that hibernate is making multiple calls to database because am setting <code>lazy="false"</code>, now i tried to change <code>lazy="true"</code> but now am getting our own :</p>
  
  <blockquote>
    <p>org.hibernate.LazyInitializationException: could not initialize proxy
    - the owning Session was closed </p>
  </blockquote>
  
  <p>error message. </p>
  
  <p>I did some research on <code>SO</code> and found that solution could be </p>
  
  <pre><code> &lt;prop key="hibernate.default_batch_fetch_size"&gt;30&lt;/prop&gt;
   &lt;prop key="hibernate.jdbc.fetch_size"&gt;&lt;/prop&gt;
  </code></pre>
  
  <p>and my question is what would be default size of fetch_size and if this is right way to solve this problem. </p>
  
  <p>All i want to do is make sure that application does not make multiple calls to database to run all those <code>N</code> queries as right now navigating between page is lot of pain and makes application very slow as on every page click, there are <code>N</code> of queries that are run in the background and it increases application load time. </p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is the how am setting transactions:</p>
  
  <pre><code> * @hibernate.class table="SCHEDULE_ENTRY" discriminator-value="task" lazy="true"
   * @hibernate.discriminator column="KIND" length="4"
  </code></pre>
  
  <p>Would highly appreciate any suggestions to improve performance of hibernate. </p>