-->
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: Configure SessionFactory
PostPosted: Fri Jul 13, 2007 8:27 pm 
Newbie

Joined: Wed May 16, 2007 7:33 pm
Posts: 3
Hi,

I want to change the configuration at runtime ie enable/disable "hibernate.show_sql" property. I see that I can do it thru either xml file or thru configuration object. However, once SessionFactory is created out of configuration object, it will be static forever? Can I can set any properties after SessionFactory is created ? I want to set the "hibernate.show_sql" property after SessionFactory is created. Is this possible? Or do I have to create a new SessionFactory everytime, I change the configuration object?

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 14, 2007 8:34 am 
Expert
Expert

Joined: Fri Jul 13, 2007 8:18 am
Posts: 370
Location: london
Basically you're not allowed to change the settings once the factory is configured.

You could create 2 factories - 1 with show_sql=true, one with show_sql=false and choose which to use at runtime. For example, by adding a static setShowSqlEnabled method to HibernateUtil to decide which factory to generate a Session from, or adding a showSql parameter to getSession.

Mike


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.