• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate - slow at startup/mapping

 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

as I got my problem with mappings in the "hibernate.cfg.xml"-file solved in another thread, I am now wondering about the average startup/mapping time of hibernate.

I am building a fat client with Java8 and JavaFX, using hibernate 5.0.0 for persistence with a "hibernate.cfg.xml" file for configuration and ".hbm.xml"-files for each persisted class.

Turning on hibernate increases the startup-time significantly. Right now, I have about 30 persisted classes with - as I would say - simple complexity and only few members. When building the SessionFactory with the code pauses after the info-message INFO: HCANN000001: Hibernate Commons Annotations {5.0.0.Final} for about 15 seconds - this time varies with the number of mapped classes, so each mapping seems to take about 500ms. Is this normal behaviour??? As the application is still growing, the number of persisted classes will increase as well, making the startup time even longer...

I found lots of resources about performance tuning of queries on the internet, but nothing on the average startup time.

Could anybody tell me, how I can analyse, what is happening while hibernate is mapping the classes and whether it is possible to speed up this process?
Andy
 
Marco Behler
Author
Ranch Hand
Posts: 43
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,
in general, 15 seconds is not normal and looks a bit suspicious for 30 persisted classes.

You might try the Java Config/Annotation mapping and save maybe a little bit of time, but I don't have comparison numbers handy.

Nevertheless, hibernate WILL take more time on startup. If you want to be faster, you could use JooQ or plain JDBC or make your SessionFactory lazy-initialized if possible.



 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

thank you for your answer and sorry for my late reply - I needed to postpone my work on hibernate for some weeks. In a new approach, I linked the hibernate sourcecode to my own sources and debugged line for line to find out, what is happening.

The delay occurs in the class "MappingBinder" (package org.hibernate.boot.jaxb.internal;) in the method "doBind". It calls in the "abstractBinder"-class of the same package. Here, the line is responsible for the delay.

As far as I can see, the jaxbContext is the same in every method-call. Nevertheless it gets instantiated with every "hbm.xml"-file I add. Am I missing anything??? If this object would be instanciated only once, my startup-time would decrease significantly...
 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue seems to be new with version 5.0.0 and was reported on JIRA on the official hibernate website. Unfortunately, although it is is marked as fixed with version 5.0.1 it is still present, even in the newest version 5.0.2. I posted a comment and hope for the problem to be fixed soon.
The hibernate team already posted the necessary code changes, but till now I am not able to include the sources in my application...
 
A. Koch
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As it seems, the fix was somehow forgotten to be ported to the new branch of hibernate. As JIRA-issue HHH-10170 states, it will be fixed in Version 5.0.3. I consider this topic as solved then.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic