I need to process a CSV file and for each record (line) persist an entity. Right now, I do it this way:
while ((line = reader.readNext()) != null) {
Enti
To make it go faster, at least in Hibernate, you would do a flush() and a clear() after a certain number of inserts. I have done this approach for millions of records and it works. It's still slow, but it's much faster than not doing it. The basic structure is like this:
int i = 0;
for(MyThingy thingy : lotsOfThingies) {
dao.save(thingy.toModel())
if(++i % 20 == 0) {
dao.flushAndClear();
}
}