tags:

views:

64

answers:

2

In my Java SE application I used Hibernate 3.3.2 and creating the SessionFactory took about 5 seconds.

Today I updated to Hibernate 3.5.1 and suddenly it takes over a minute.

What can be the cause of such a dramatic effect?

I tried different things the better part of the day and I have no clue...

Some data I collected

  • According to the profiler the most time is spent in PersisterFactory.createClassPersister and in that method ProxyFactory.createClass takes the most time.
  • The log shows nothing unusual
  • Changing hibernate.bytecode.use_reflection_optimizer makes no difference
A: 

Er there never was a Hibernate 3.4. Hibernate 3.3.2 was last public release before Hibernate 3.5

MJB
Ahhhh, that's why the OP is experiencing this problem ;)
Pascal Thivent
I re-checked and yes it was 3.3.2
DR
Try reducing the number of classes mapped as resources to see if you can isolate the issue. For example, map only one class and time that and compare to the older code.
MJB
A: 

OK, this was absolutely stupid and had nothing to do with Hibernate at all, but I'll answer that question anyway, because it might prevent others to do the same mistakes.

  1. Creating the SessionFactory in Hibernate 3.5 is not slower.
  2. When creating the SessionFactory there are thousands of methods calls in order to initialize Hibernate.
  3. Each of these method calls seem to produce a small overhead for the profiler and the debugger. Also the JIT compiler is disabled during debugging.
  4. The first time I noticed the slowness I was single-stepping through the code and all subsequent tests were done using a profiler.
  5. I only noticed that because in frustration I just ran the application without any intent to further track down the problem.
DR