-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how speedup hibernate boot
PostPosted: Sun Jun 12, 2011 6:10 am 
Beginner
Beginner

Joined: Sun Jan 30, 2011 8:14 am
Posts: 24
Dear all,
I've just a question for you.
I developed a java application that uses hibernate.
My only issue is that boot of application requires several seconds.
Is there a way to speed up hibernate boot?
I show my configuration file, please let me know if I missed something:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
    <property name="hibernate.connection.driver_class">org.apache.derby.jdbc.EmbeddedDriver</property>
    <property name="hibernate.connection.url">jdbc:derby:xxx</property>
    <property name="hibernate.connection.username">yyy</property>
    <property name="hibernate.connection.password">zzz</property>
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="hibernate.connection.autocommit ">false</property>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.format_sql">true</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <mapping class="app.entity.Cap"/>
    <mapping class="app.entity.entity1/>
    <mapping class="app.entity.entity2"/>
    <mapping class="app.entity.entity3"/>
....   
  </session-factory>
</hibernate-configuration>


PLease help me, thanks


Top
 Profile  
 
 Post subject: Re: how speedup hibernate boot
PostPosted: Tue Jun 14, 2011 8:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Once your entity meta-model is stable (= reached a definitive database schema)
you should ommit the property:
<property name="hibernate.hbm2ddl.auto">update</property>

This should speed up the initialization of the session-factory as you skip this step.

Beside of this the most time on bulding the session-factory is spent in parsing and building the meta-model.
There I made following experciences:
-the more complex you meta-model is, as longer the session-factory takes to parse your meta-model.
So define less entity classes and relations as possible, just the essential and necessary ones.
-on certain operating systems (actually MSWindows) sometimes the classloader spent very long time in scanning jar files for entity classes when using the hibernate.archive.autodetection feature.
In this case it was useful to put all entity-classes in a separate jar-file and specifying it in the <jar-file> tag (JPA approach)
-initialization of the session-factory became faster when upgrading from hibernate 3.2 to 3.5
Which version of hibernate are you using?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.