Hibernate is clearly a great ORM. However its speed in inserting complex cascading object graphs leaves something to be desired because each object is persisted serially in the order that the cascade is called. When inserting a large number of identical objects batching cannot be used since inserts cannot be grouped by the JDBC batching mechanism.
e.g. A has two children B and C that both have fks to the A. If I persist n As the insert order is
insert A
insert B
insert C
insert A
insert B
insert C
...
...
The number of insert statements generated is n * (1 + total number of children in the tree) that A has to insert. For high latency connections this is a killer on performance.
In some cases it is possible to rearrange the inserts so that you group all the objects of similar a similar type together
e.g.
insert A
insert A
...
insert B
insert B
...
insert C
insert C
Then the hibernate can batch similar inserts together and reduce the number of round trips (plus the savings on the server side).
We have a patch that works for us to do this, but it obviously needs testing on other peoples insert graphs. We have experienced several hundred percent speed increase in our real world testing.
Please see
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1
to get the patch against the 3.2 . Any and all feedback would be appreciated.