title: Using join based on a non-entity object
body: <p>I have the following structure:</p>
  
  <pre class="lang-none prettyprint-override"><code>Table1
    T1_ID
    T1_Col1
  
  Table2
    T1_ID
    T3_ID
  
  Table3
    T3_ID
    T3_Col1
  </code></pre>
  
  <p>I have entity objects for <code>Table1</code> and <code>Table3</code>. However, I don't have and entity object for <code>Table2</code>. I don't want to create it because I would then have to go a longer route of creating a composite key for the entity, etc. </p>
  
  <p>What I want to use is a query like this:</p>
  
  <pre class="lang-sql prettyprint-override"><code>select t3 from Table1 t1, Table2 t2, Table3 t3
  where t1.t1_id=:id
  and t2.t1_id=t1.t1_id
  and t2.t3_id=t3.t3_id
  </code></pre>
  
  <p><strong>Actual problem</strong></p>
  
  <p>I have a repository for <code>Table1</code> which has <code>Table3</code> configured as <code>lazyloading</code>. However, when I try to access after fetching <code>Table1</code> by <code>primarykey</code>, I get the exception <code>org.hibernate.LazyInitializationException</code>.</p>
  
  <p>After doing some research, I figured out that I don't have session available there. I tried a couple of workarounds but none worked. Given that the persistent framework is written by another team, I don't have much knowledge to see if it can be done. So i am looking at this solution, which might be easier.</p>