Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] MemoryLeak by CursoredStream??


I use eclipselink and it's very nice. Our backend DB is MSSQL. I have to run pagination to millions of records. It seems eclipselink doesn't support setFirstResult/setMaxRows Pagination about MSSQL.
Using above method, performance wasn't good because MSSQL pagination query(FETCH OFFSET) isn't used.

So, I tried to use CursoredStream as below.
The problem is even if cursor.clear() is called, all record objects remain in UnitOfWork object as DescriptorEvent. I have to update records so "READ_ONLY" query hint can't be used.
int max = 1000;
query.setHint(QueryHints.CURSOR, HintValues.TRUE)
		.setHint(QueryHints.JDBC_FETCH_SIZE, max);
CursoredStream cursor = (CursoredStream)query.getSingleResult();
while (cursor.hasNext()) {
	list =;
	for (Object recordObj : list) {
		RecordEntity record = (RecordEntity)recordObj;
		record.setSomeValue(someValue); // the record has to be updated
	cursor.clear(); //cursor.releasePrevious() doesn't work as well
Is it possible paging records by CursoredStream without getting all records in memory? If anyone could tell me, it's really helpful.

Thank you,

Back to the top