title: Importing a csv file to a MySQL database using Hibernate
body: <p>I am trying to import a csv file to a MySQL database, and I created a script in groovy for doing that using Hibernate. The thing is, the csv file is quite huge, it has about 48 million lines. I was opening a session and committing a transaction for each line, but then I saw that this would take a long time. By the pace of rows added to the database after one day running the script, it would take more than one month to export everything. So, I thought that maybe, the bottleneck was at opening a session and committing a transaction for every line... then I decided to open just one session, read every line, instantiate an entity for every single line, save it on the session, and after reading all the 48 millions lines and storing the 48 millions entities in the session, commit one single transaction with all these instances. Well, that didn't work either. Is there any way of importing this csv file to a mysql database in a much faster way? Or it should really take that long?</p>