loop through objects in database from starting object to ending object
<p>I have a table named week with columns <code>weekid</code>, <code>weeknumber</code> and <code>weekyear</code>.
Given a starting week I want to get the next 9 weeks (for a total of 10) or the next weeks up to the current week.</p>

<p>I have this:</p>

<pre><code>Week weekFirst = weekDao.getWeekByID(20);           
Week weekLast = weekDao.getWeekByID(30);
List&lt;Week&gt; weekList= new ArrayList&lt;Week&gt;();

for(int i=weekFirst.getWeekid(); i&lt;=weekLast.getWeekid();i++){
     weekList.add(weekDao.getWeekByID(i));
     if(weeksDAO.getWeekByID(i).getWeeknumber() == now.get(Calendar.WEEK_OF_YEAR)){
          break;            
}
</code></pre>

<p>But this won't do cause it gets only the weekId instead of Week Itself(The Object)</p>

<p>I need to get the Object Week itself and put it in the list so it doesn't add the Week by the next weekId but it adds according to the next Week Object.</p>
