Configuration in Hibernate.cfg.xml when using the following databases
Microsoft SQL Server 2005/2000 is configured as follows:
<?xml version= "1.0"?>
<session-factory>
<property name= "Connection.provider" >nhibernate.connection.driverconnectionprovider</property >
<property name= "dialect" > nhibernate.dialect.mssql2005dialect</property>
<property name= "Connection.driver_class" >NHibernate.Driver.SqlClientDriver</property>
<property name= "connection.connection_string" >server= (Local ); Initial Catalog=dbname; User Id=user; password=********</property>
</session-factory>
</ hibernate-configuration>
SQL2000 words change dialect to NHibernate.Dialect.MsSql2000Dialect.
One question to note: If SQL Server does not select a column in the select middle, sometimes the ORDER BY clause ignores these special columns, and this behavior is valid in standard SQL, for example, a query like this is not guaranteed to be correct: from the person P order by P.company.name
Oracle configuration is as follows:
Both Oracle 9i and 10g support references to Microsoft Driver (System.Data.OracleClient) and Oracle Driver (Oracle.Data.OracleClient).
One thing to note: When the length in the string argument is 20000-4000, the Microsoft driver does not handle long characters correctly, and Oracle cannot accept empty strings, you can use NULL instead, Iusertype implementation transformation in the Nullables.nhibernate class of the Nhibernatecontrib package
Microsoft access is configured as follows:
Microsoft access has its own dialect and driver, in NHibernate.JetDriver.dll in the Nhibernatecontrib package.
<?xml version= "1.0"?>
<property name= "dialect" >nhibernate.jetdriver.jetdialect, Nhibernate.jetdriver</property
<property name= "Connection.driver_class" > NHibernate.JetDriver.JetDriver, Nhibernate.jetdriver</property>
<property name= "connection.connection_string" >provider=microsoft.jet.oledb.4.0;data Source=yourdatabasefilepathhere.mdb</property>
</session-factory>
Firebird
To use Firebird first install the latest fire bird. NET Data provider installed in the GAC (that is, a standard installation), add the following node to your application configuration file (app. config or Web. config):
<runtime>
<assemblybinding xmlns= "Urn:schemas-microsoft-com:asm.v1" >
<qualifyassembly partialname= "FirebirdSql.Data.FirebirdClient"
Fullname= "FirebirdSql.Data.FirebirdClient, version=2.0.1.0, culture=neutral, publickeytoken=3750abcc3150b00c"/ >
</assemblyBinding>
</runtime>
The version here depends on the edition you installed.
<session-factory name= "Nhibernate.test" >
<property name= "Connection.provider" >NHibernate.Connection.DriverConnectionProvider</property>
<property name= "Connection.driver_class" >NHibernate.Driver.FirebirdClientDriver</property>
<property name= "Connection.isolation" >ReadCommitted</property>
<property name= "Connection.connection_string" >
Server=localhost;
Database=c:\nhibernate.fdb;
USER=SYSDBA; Password=masterkey
</property>
<property name= "Show_sql" >false</property>
<property name= "dialect" >NHibernate.Dialect.FirebirdDialect</property>
<property name= "Use_outer_join" >true</property>
<property name= "Command_timeout" >444</property>
<property name= "Query.substitutions" >true 1, False 0, yes 1, no 0</property>
</session-factory>
2.0.1 all Firebird embedded functions and IB_UDF2.SQL user-defined functions are included in the dialect, and these functions can be used directly in HQL.
PostgreSQL
We recommend that you use a later version of PostgreSQL 7.4
<?xml version= "1.0" encoding= "Utf-8"?>
<session-factory name= "Nhibernate.test" >
<property name= "Connection.provider" >NHibernate.Connection.DriverConnectionProvider</property>
<property name= "Connection.driver_class" >NHibernate.Driver.NpgsqlDriver</property>
<property name= "Connection.connection_string" >
Server=localhost;initial catalog=nhibernate; User id=nhibernate; password=********;
</property>
<property name= "dialect" >NHibernate.Dialect.PostgreSQLDialect</property>
</session-factory>
Mysql
<?xml version= "1.0" encoding= "Utf-8"?>
<session-factory name= "Nhibernate.test" >
<property name= "Connection.provider" >NHibernate.Connection.DriverConnectionProvider</property>
<property name= "Connection.driver_class" >NHibernate.Driver.MySqlDataDriver</property>
<property name= "Connection.connection_string" >
Database=test;data Source=someip; User Id=blah; Password=blah
</property>
<property name= "dialect" >NHibernate.Dialect.MySQLDialect</property>
</session-factory>
One problem to note: MySQL has a special feature that allows date fields to be invalid, and there are no null columns, and the default value is 0000-00-00. When a MySQL connector encounters such a date, it either throws an exception or returns a non-standard Mysqldatetime object (a connection string parameter) that throws an exception when converted to datetime itself.
Possible workaround: Avoid the 0 period; Modify the connector (NET source code) to random or 0 datetime.minvalue; Create mysqldatetime user type (no known implementation currently);
Sqlite
Download the Using ADO provider from Http://sourceforge.net/projects/adodotnetsqlite.
<?xml version= "1.0" encoding= "Utf-8"?>
<session-factory name= "Nhibernate.test" >
<property name= "Connection.provider" >NHibernate.Connection.DriverConnectionProvider</property>
<property name= "Connection.driver_class" >NHibernate.Driver.SQLiteDriver</property>
<property name= "Connection.connection_string" >
Data source=nhibernate.db; Version=3
</property>
<property name= "dialect" >NHibernate.Dialect.SQLiteDialect</property>
<property name= "Query.substitutions" >true=1;false=0</property>
</session-factory>
NHibernate Supported Configurations in database nhibernate connection configuration Hibernate.cfg.xml