title: Hibernate select query with different where clause
body: <p>This might be quite simple but I have spent hours in Google but couldn't find a relevant answer.</p>
  
  <p>I am trying to put the below logic into hibernate but i am not able to figure out how.
  This is my setup: Mysql database with 2 tables T1(ID,C1,C2) and T2(column1,column2,column3). 
  This is what I want to implement</p>
  
  <pre><code>    results = select ID, from T1 //This will result in multiple rows.
  
      for(eachRow in results )
      {
      select column1,column2,column3 from T2 where ID=eachRow.ID
      //Do some computation like
      //Assign value of table "T1" column "C1" to table "T2" column "column1"
      column1 = eachRow.C1
  
      }
  </code></pre>
  
  <p>For now I could think of a logic of reading the entire table using the Hibernate "from" clause into a List and iterating through it. However this might cause a OutOfMemory exception. Could you please suggest how the HQL must be?</p>
  
  <p>This is what I did   </p>
  
  <pre><code>Session session = HibernateSession.getSessionFactory().openSession();
          Transaction aTableTx = null;
          try {
              aTableTx = session.beginTransaction();
  
              _allRows = session.createQuery("from T1").list();
  
              for (Iterator&lt;T1&gt; iterator = _allRows.iterator(); iterator.hasNext();)
              {
                  T1 aRow = iterator.next();
                  //Here I am planning to run a similar to
                              //_allRows = session.createQuery("from T2").list();
                              //Store the result and iterate through the list, but 
                              //it is very inefficient.
              }
  
              aTableTx.commit();
  </code></pre>