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.  [ 7 posts ] 
Author Message
 Post subject: Saving the configurations and mapping
PostPosted: Mon Jun 08, 2009 3:03 pm 
Newbie

Joined: Thu Jun 12, 2008 10:52 am
Posts: 16
Hello,

The fat client Java application we are currently working on is using more than 800 mapping file. The configuration and the file mapping are always restarted when the application is restarted (sorry I don't think we can change that). So my question is, is there a way to optimize this loading time ? Maybe by serializing and saving to a binary file the final configuration and/or mapping state. So the next time we launch the application we load the all thing from those files (I'm pretty sure parsing binary is quicker than parsing XML :)).
What do you think of that ? Anybody has a better solution ? Is there already a solution for our problem somewhere ?

Thank you


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Mon Jun 08, 2009 3:46 pm 
Beginner
Beginner

Joined: Mon Jun 01, 2009 5:39 am
Posts: 34
Well, the Configuration object implements Serializable.


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Mon Jun 08, 2009 4:37 pm 
Newbie

Joined: Thu Jun 12, 2008 10:52 am
Posts: 16
Yes i saw that, but i was wondering if that would be enough. Do you think so ?


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Tue Jun 09, 2009 3:24 am 
Beginner
Beginner

Joined: Mon Jun 01, 2009 5:39 am
Posts: 34
Yes it will. The Configuration object doesn't activate anything, it's only when you build the SessionFactory that the caches are activated, the JDBC pool is spawned, etc.

You only have to load all the configuration properties (either hibernate.properties or hibernate.cfg.xml), the mappings (if they are not already declared in hibernate.cfg.xml), and you should be good to go.


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Tue Jun 09, 2009 2:38 pm 
Newbie

Joined: Thu Jun 12, 2008 10:52 am
Posts: 16
Okay thanks for the tips.
I had some issues serializing the all object so I come up with a different solution. Just serializing all the mapping using addCacheableFile(). I've a class inheriting from Configuration and changed the default behavior to use addCacheableFile (in parseMappingElement()) instead of just addFile().

Anyway, I have just benchmarked my SF building process and it takes about 13s. Do you think is it still possible to enhance the process or you guys think you have just reach the limit :D ? I'm saying this because of this topic : https://forum.hibernate.org/viewtopic.php?t=942577


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Tue Jun 09, 2009 2:52 pm 
Beginner
Beginner

Joined: Mon Jun 01, 2009 5:39 am
Posts: 34
Do you .buildMappings() on your Configuration object before serializing it?


Top
 Profile  
 
 Post subject: Re: Saving the configurations and mapping
PostPosted: Tue Jun 09, 2009 4:10 pm 
Newbie

Joined: Thu Jun 12, 2008 10:52 am
Posts: 16
Heum buildMappings is calling secondPassCompile() ; secondPassCompile() is called by buildSessionFactory() ; And I'm calling buildSessionFactory() before serializing.. Is that a bad thing ? Why is that so ?

I tried to serialize the configuration before building the SF but I'm getting a java.io.NotSerializableException: org.hibernate.engine.query.sql.NativeSQLQueryScalarReturn

Serializing my 800 mapping files made me win 1 sec approximately (addFile() => 5125 ms vs second pass with addCacheableFile() => 4031ms), I'm not sure serialzing the configuration is going to make things go much faster.


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