Hello
I'm a newbie to hibernate and testing for our purposes. We will have large datasets (several million entries), that are not presented all together, but page by page (maybe 500 entries).
I wrote a sample application, which simply prints the entries to the console (instead of a swing-gui).
I tried to use "ScrollableResults", but after about 700'000 entries I still get a "java.lang.OutOfMemoryError". I suppose it is, because it doesn't dispose old results... (?)
How can i process the results in a matter, that page by page is loaded from the database to the application?
I'm thankful for any type of advice!
thanks,
baer
system-info:
oracle 9 database
hibernate 2.1.3
if needed i'm happy to pass on mapping docs.
code:
Code:
private void printScrollableResult() {
try {
Configuration cfg = new Configuration();
SessionFactory sessionFactory = cfg.configure().buildSessionFactory();
Session session = sessionFactory.openSession();
String querySt = "select dyncdr_t from dyncdr_t " + " in class DyncdrT";
Query q = session.createQuery(querySt);
ScrollableResults cdrs = q.scroll();
cdrs.beforeFirst();
int i = 0;
do {
i = 0;
while (i < PAGE_SIZE && cdrs.next()) {
msg(new String("row = ") + new Integer(cdrs.getRowNumber()) + new String(": id=") + new String(cdrs.getString(0)));
i++;
}
msg("------- end of page --------");
}
while (cdrs.scroll(PAGE_SIZE));
}
catch (HibernateException he) {
// TODO Auto-generated catch block
he.printStackTrace();
}