Why doesn’t Hibernate do batch?
We have recently run across a couple of situations that are really batch operations. You know read N records of type Y or write M records of type Z, all within a nice Hibernate session/transaction of course.
If you do the brain-dead coding looping over calls to object.setX(), object.save(), you are making a round trip from your logic layer all the way to the database (including the cache) for every loop step.
There is also the slight problem that you may run out of memory with a large operation as all of this has to sit in the cache until flushed out.
Looking at some literature points to the Hibernate batch size, but others say this really doesn’t work.
Others are more extreme and point to using raw SQL to perform your batch.
Why aren’t there batch calls sitting in Hibernate? This is not a new persistence problem.

Comments
Leave a comment Trackback