I am completely new to both spring and hibernate (a couple of weeks). I have been toying with a trivial test program using hibernate and hibernate/spring. After getting past the worst part of the green-newbie learning curve, I found myself somewhat comfortable with both. However, I noticed that plain hibernate3 is many times faster than hibernate3/spring. I eliminated some of the obvious mistakes with spring (e.g. make sure and use dbcp pooling, ...), and that made things faster, but it is still pretty bad. The worst performance hit seems to be when I insert many collection items (simple strings) into an object. If I do it with plain hibernate3, it is very fast. Spring does something that slows things down by several orders of magnitude, but I have not been able to figure out what. For instance, if I insert 50 strings into a collection, plain hibernate3 will take 0.0n seconds. With spring, it will take up to 2 seconds. I'm not sure why and it is not obvious where to look. The hit seems to be in the spring flush() operation.
I tried to read the spring code and never could figure out what it could be doing to slow things so badly. I quickly got lost in the weeds here. I noticed that the spring hibernate3 code, for example never does begin/commit transactions and relies on the session close autocommit (???). I do not know if that would make any performance difference.
I'm sure that there is some obvious configuration knob that I have not yet found that will make things behave better. However, I found it a lot less time consuming to just write the hibernate code that I need rather than try to figure out how spring was getting in the way rather than helping. This is too bad because I really wanted to use the "free" transaction management and exception handling from spring.
_________________ Julio Garcia
|