java - Spring MVC + hibernate batch loading from db -
sorry guys if trivial question, want figure out right way. there large table 'account' (about 10000 entries). want iterate through logic entity , merge if needed. don't want load entries in memory.
currently this
list<account> accounts = accountsdao.all(); (account a: accounts) { dosomecode(a); accountsdao.merge(a); }
how can improve it?
have @ setfirstresult
, setmaxresults
rather manually , quite explicit queries (think sql's limit
clause).
there setfetchsize
let driver/database chunk results of unlimited query (example in postgresql jdbc docs). scrollableresults
seems quite similar (regarding usage @ least): getting result iterator scroll on matched records (example in random blog post).
as question database using: there differences between databases and/or drivers. not know specifics here, features regarding loading in chunks must supported respective db driver.
Comments
Post a Comment