Need Solution to reduce object creation, used spring - but have a problem , method explained in detail
<p>I am using spring to reduce new objects creation, for the number of resultset available, I will create a row object inside and add the row object in a rowset object, which maintains a list of rows.</p>

<p>My code goes like this.</p>

<pre><code> while(rs.next()) {
   Row r = new Row();
   //Logic
   rowset.addRow(r);
}
</code></pre>

<p>My rs will have atleast a minimum of 3000 rows, so there will be a 3000 row object injected, so to avoid it, I used spring injection like</p>

<pre><code> while(rs.next()) {
    Row r = (Row)getApplicationContext().getBean("row");
   //Logic
   rowset.addRow(r);
}
</code></pre>

<p>but the problem here is when the second row object is added to the rowset, the first row object's values are overriden with second row object and when last row is added , all the 1 to last-1 row objects values are updated as last row object values. </p>

<p>This is my rowset calss</p>

<pre><code>public class RowSet {
 private ArrayList m_alRow;
 public RowSet() {
 m_alRow = new ArrayList();
 }
 public void addRow(Row row) {
 m_alRow.add(row);
 }
}
</code></pre>

<p>I need a solution , such that the new row object creation is avoided inside the while loop with the same logic involved.</p>
