-->
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.  [ 6 posts ] 
Author Message
 Post subject: Why it takes so long to build session factory?
PostPosted: Sat Apr 17, 2004 8:43 am 
Beginner
Beginner

Joined: Sat Jan 31, 2004 10:09 am
Posts: 26
hi, my application have more than 70 entities to be used. Each time the application starts up, it takes me such a long time to wait Hibernate builds the session factory.
Code:
11467 [main] INFO  net.sf.hibernate.impl.SessionFactoryImpl  - building session factory
34680 [main] INFO  net.sf.hibernate.impl.SessionFactoryObjectFactory  - no JNDI name configured


As you can see above, it took almost 24 seconds to build these entities.
I am poor so that I only have P III 850 CPU and 512MB ram. But I don't want to buy a new one because of this problem.

Do you have any instruction to speed up the building process?

thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2004 8:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
maybe serialize sessionFactory and desirialize it at startup


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 2:57 am 
Newbie

Joined: Thu Mar 23, 2006 11:14 am
Posts: 6
When trying to deserialize a SessionFactory from file I get the following output:

Code:
2006-04-18 08:39:47,678 WARN  [main] impl.SessionFactoryObjectFactory: Not found: 59548a9d0aabb990010aabb999e00000
2006-04-18 08:39:47,678 WARN  [main] impl.SessionFactoryObjectFactory: Not found: null
2006-04-18 08:39:47,678 DEBUG [main] util.HibernateInventoryUtil: Exception while reading sessionfactory from file: Could not find a SessionFactory named: null

Code to store sessionfactory:
Code:
sessionFactory = new Configuration()
    .configure( "hibernate.inventory.cfg.xml" )
    .buildSessionFactory();
ObjectOutputStream oos = new ObjectOutputStream( new FileOutputStream( filename ) );
oos.writeObject( sessionFactory );
oos.close();

Code to read:
Code:
ObjectInputStream ois = new ObjectInputStream( new FileInputStream( filename ) );
sessionFactory = ( SessionFactory )ois.readObject();
ois.close();


I'm usin gHibernate 3.0. Bye


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 3:26 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
do you have a name for your session factory? :

Code:
<session-factory name="inventory">


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 5:00 am 
Newbie

Joined: Thu Mar 23, 2006 11:14 am
Posts: 6
Thanks for the advice. Now I get:

Code:
2006-04-18 10:56:27,018 WARN  [main] impl.SessionFactoryObjectFactory: Not found: 59548a9d0aac3659010aac3662030000
2006-04-18 10:56:27,018 WARN  [main] impl.SessionFactoryObjectFactory: Not found: inventory
2006-04-18 10:56:27,018 DEBUG [main] util.HibernateInventoryUtil: Exception while reading sessionfactory from file: Could not find a SessionFactory named: inventory


Also when the factory is built:
Code:
2006-04-18 10:56:29,909 INFO  [main] impl.SessionFactoryImpl: building session factory
2006-04-18 10:56:32,221 INFO  [main] impl.SessionFactoryObjectFactory: Factory name: inventory
2006-04-18 10:56:32,221 INFO  [main] util.NamingHelper: JNDI InitialContext properties:{}
2006-04-18 10:56:32,221 WARN  [main] impl.SessionFactoryObjectFactory: Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
   at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
   at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
   at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
   at javax.naming.InitialContext.getNameParser(InitialContext.java:439)
   at org.hibernate.util.NamingHelper.bind(NamingHelper.java:52)
   at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:260)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
   at com.teliasonera.wal.inventory.util.HibernateInventoryUtil.init(HibernateInventoryUtil.java:29)


Thanks for helping me! Bye,
Dag.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 20, 2006 10:51 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
Try serializing the Configuration object instead of the SessionFactory.

http://opensource.atlassian.com/projects/hibernate/browse/HB-492
http://forum.hibernate.org/viewtopic.php?t=958364


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.