Hi folks
I'm facing a severe situation with the following:
I must query thousands of objects and iterate through them all to do certain processing with each instance.
To achieve this I created a query:
Code:
Query query = session.createQuery("from Bill as b where b.date = ?");
query.setParameter(0, new Date());
Iterator results = query.iterate();
Then, for each iteration I must also create and persist a new instance of another bean:
Code:
while (results.hasNext()) {
// do my processing ...
Payment payment = new Payment();
// set some payment's attribuites
session.save(payment);
}
The first problem is that every instance loaded goes to the first level cache increasing the memory usage (about 62MB) until I get an OutOfMemoryException. To solve this I tried to evict each instance from the cache after using it, calling session.evict(), but the memory allocation continues to increase, though in a smaller rate (about 29MB), as I observed in W2K Task Manager.
The second problem is that the new instances of Payment also go to the cache and I would have the same problems to evict them.
Any comments will be wellcome.
Thanks.