Posts

on spring, hibernate and batch insert-update

Most programming examples are about small amounts data processed, as it is the sufficient amount to demonstrate ideas. However one can sometimes run into cases involving insertion/update of 100k+ rows in a short amount of time and see that it's not practical with all default settings. Batch INSERTs and UPDATEs In most cases, every INSERT or UPDATE command to the database has a cost of sending a command through the network stack. The DBMS spends microsecond-level time to fulfil the command and the network takes millisecond-level time for the trip. JDBC API has a batch capability so that one can do more efficient than a command (and a millisecond trip) per row to be inserted. Batch Updates with Hibernate One can declare a batch-size attribute in the configuration and those entities begin. Not a bad idea if There's no need for insertion or the key property is not identity, as there's no standard way to batch-read generated keys. Objects with keys generated by the data...

Motivation

Unlike many of my colleagues and like many more others I did not have a technical blog as I do not so often run into stuff that is worth writing. Recently I was asked if I had one, not because there was a problem around and a solution was needed. I was asked for a blog so that someone else can have an idea about what kind of developer I am. This is a blog about my solutions to my everyday problems. More optimal solutions may exist; others might have come up with similar or better solutions well before than I did. This blog contains wheels in the way I invented them. It might be useful for those tired of googling around for better solutions and came here somehow. The reader is free to copy and paste as long as everyone knows the source.