-->
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.  [ 3 posts ] 
Author Message
 Post subject: Global (static) configuration without config problem
PostPosted: Wed Jan 23, 2008 6:04 am 
Newbie

Joined: Wed Jan 23, 2008 5:54 am
Posts: 2
How to set configuration properties globally without using config file?

NHibernate.Cfg.Environment.Properties[NHibernate.Cfg.Environment.ConnectionString] = "xxx";
it doesn't works!

"System-level properties can only be set manually by setting static properties of NHibernate.Cfg.Environment class or be defined in the <nhibernate> section of the application configuration file."

looking forward to some help


Top
 Profile  
 
 Post subject: Global (static) configuration without config problem
PostPosted: Wed Jan 23, 2008 7:16 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi digiboo,

The property NHibernate.Cfg.Environment.Properties returns you a copy of the global properties, so you cannot modify it.

Typically, you want to create a global (singleton) ISessionFactory with the appropriate configuration and use that to create ISession instances.

Code:

Configuration cfg = new Configuration();
cfg.Add(NHibernate.Cfg.Environment.ConnectionString, "xxx");

ISessionFactory factory = cfg.BuildSessionFactory(); // <- this can be global

ISession session = factory.OpenSession();



Regards,
Richard


Top
 Profile  
 
 Post subject: Re: Global (static) configuration without config problem
PostPosted: Wed Jan 23, 2008 7:45 am 
Newbie

Joined: Wed Jan 23, 2008 5:54 am
Posts: 2
Thanks a lot.
Unfortunately it used in third-party library which hasn't singleton prorery to access configuration instance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.