-->
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.  [ 5 posts ] 
Author Message
 Post subject: Newbie Question - manually configuring NHibernate.Dialect
PostPosted: Thu May 19, 2005 1:51 am 
Newbie

Joined: Sun May 15, 2005 11:39 pm
Posts: 17
Location: Australia
Hi all,

Sorry if this question seems blatently obvious... however I can't seem to find an answer.

How do I configure NH manually (ie, without the app.config file)?

Where for example do you set NHibernate.Dialect?

I assume it is one of the methods of NHibernate.Cfg.Configuration... Do you do this before building a session factory?

Could someone please give me an simple example?

Thanks in advance,



Damien Sawyer


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 3:30 am 
Newbie

Joined: Wed May 18, 2005 1:28 am
Posts: 5
Location: Depok, Indonesia
There are plenty resources you can find to answer your question (Well, at least that's what I think :D ).

Here's a start:
http://wiki.nhibernate.org/display/NH/Quick+Start+Guide

Or maybe you've been there? For me, it is a clear simple walkthrough into using NH.

O yea, configuring NH can be done programmatically. Here's an example:
Code:
            this.AmetisConfiguration = new Configuration();

            //Setting Configuration Properties
            //*
            IDictionary props = new Hashtable();

            props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider";
            props["hibernate.dialect"] = "NHibernate.Dialect.MsSql2000Dialect";
            props["hibernate.connection.driver_class"] = "NHibernate.Driver.SqlClientDriver";
            props["hibernate.connection.connection_string"] = "Server=127.0.0.1;Initial Catalog=Lexica;User ID=sa;Password=;";

            foreach( DictionaryEntry de in props )
            {
               this.AmetisConfiguration.SetProperty( de.Key.ToString(), de.Value.ToString() );
            }
            //*/



You'll need to set the appropriate value for the properties (well ... of course :D )

_________________
-Adin


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2005 8:52 pm 
Newbie

Joined: Sun May 15, 2005 11:39 pm
Posts: 17
Location: Australia
Thanks - that's great!

Out of interest, I find it interesting that these are set by strings as opposed to being able to set properties on the configuration object via enums... Does anyone know if there was some reason for this? Maybe consistance with the Java parent?

Cheers



DS


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 3:43 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, it was ported from Hibernate directly, works right, so nobody bothered to change it any further.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 5:26 am 
Probably also a future-proofing extinsibility measure. One couldn't guess all the obscure configuration properties that a RDBMS might need you to specify.


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