NHibernate 支持的数据库及配置参数

理论上支持的数据库

NHibernate is primarily tested on Microsoft SQL Server 2000. It is also known
to work on these databases:

Microsoft SQL Server 2005/2000

SQL Server 2005 and 2000 are the primary databases used by the developers of
NHibernate.

Configuration example:


<?xml version="1.0" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<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>

For SQL Server 2000, change the dialect to
NHibernate.Dialect.MsSql2000Dialect

Issues

SQL Server sometimes ignores columns specified in ORDER BY clause of
a query if they are not included in the SELECT  clause. This
behavior is actually valid according to the SQL standard,  but may be
surprising. For example, a query like this is not guaranteed  to be ordered
correctly:

from Person p order by p.Company.Name


Oracle


Oracle 9i and 10g are supported, both using Microsoft driver
(System.Data.OracleClient) and using Oracle driver
(Oracle.Data.OracleClient).

Issues

Microsoft‘s  driver does not handle long character strings correctly. An
error  happens in some circumstances when using a string of length
2000-4000 as  a parameter value.

Oracle cannot handle empty strings (""), you  should use null instead.
An IUserType implementation to perform the  conversion is contained in
Nullables.NHibernate library (part of  NHibernateContrib package).


Microsoft Access


Microsoft Access has its own dialect and driver (contributed by Lukas
Krejci).

They are currently in a separated library: NHibernate.JetDriver.dll
(in NHibernateContrib package).

Here is what your hibernate.cfg.xml file should contain when using a
Microsoft Access database:


<?xml version="1.0" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<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>
</hibernate-configuration>

Issues

There  are still few problems with join syntax in queries that use more
than  one join. This driver passes 93% of NHibernate tests (there are
23  failing tests).

The most complete topic about these issues is here: Using
NHibernate with Microsoft Access 2003 / Jet 4.0
. JIRA issues NH-124
and NH-437  have
some information on problems with implementing Microsoft Access  dialect.
You can also try searching NHibernate forum for "access jet"  (require all
words).


Firebird


Firebird is supported since version
1.5.3, though version 2.0.1 is strongly recommended. To work with Firebird,
install the latest Firebird
.NET Data Provider
.  If the data provider is installed in the GAC (the
standard behavior of  its installer), add this section 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 value of the fullName attribute will depend on the version of the assembly you have installed in the GAC.

Here is what your hibernate.cfg.xml file should contain when using Firebird:


<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
<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>
</hibernate-configuration>

All Firebird 2.0.1 embedded functions are registered in the dialect, as well
as user-defined functions from ib_udf2.sql. These functions can be used
in HQL queries.


PostgreSQL


PostgreSQL version 7.4 with latest
Npgsql works almost
perfectly. Later versions should work too.

Configuration example:


<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<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>
</hibernate-configuration>

DB2 UDB


DB2 UDB is supported and reportedly even passes all the tests (see http://nhibernate.sourceforge.net/forum/viewtopic.php?t=73).
Example configuration using the ODBC drivers that come with the ‘stinger‘
release of db2:


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >

<session-factory name="session">

<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.OdbcDriver</property>
<property name="connection.connection_string">driver={IBM DB2 ODBC DRIVER};Database=db;hostname=host;port=port;protocol=TCPIP; uid=uid; pwd=pwd</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.DB2Dialect</property>
<property name="use_outer_join">true</property>

<mapping resource="..." />

</session-factory>

</hibernate-configuration>

MySQL


All MySQL versions should work, though
there are issues with zero dates (see below for details). To connect to your
database use Connector/NET (formerly
known as ByteFX.Data.MySqlClient).

Configuration example:


<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<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>
</hibernate-configuration>

Issues

MySQL  has a unique "feature" of allowing invalid dates in a DATE field,
and  especially using 0000-00-00 as a default value for DATE NOT NULL 
columns. When MySQL Connector encounters such a date, it either throws  an
exception or returns a non-standard MySqlDateTime object (depending  on a
connection string parameter) which throws an exception when  converting
itself to a DateTime.

Possible workarounds:

  • avoid zero dates

  • modify Connector/NET source code to round zero dates to DateTime.Min and
    back (see JIRA issue NH-32 for a patch to an
    older version of the Connector)

  • create a user type for MySqlDateTime (no known implementations
    currently)


SQLite


SQLite version 3 works rather well using
ADO.NET provider available from http://sourceforge.net/projects/adodotnetsqlite.
NHibernate Query Analyzer uses SQLite (see [Related Projects]).

Configuration example:


<?xml version="1.0" encoding="utf-8"?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<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>
</hibernate-configuration>

Issues

SQLite  currently fails 17 tests out of approximately 500 in NHibernate
test  suite. Some of the failures are caused by SQLite being unable to
store  strings containing NUL characters, other tests fail because of a bug
in  SQLite ADO.NET provider when using a table with spaces in its name.

以上为转载,原文请参见:http://www.cnblogs.com/dzone/archive/2011/04/01/2001828.html

NHibernate 支持的数据库及配置参数,码迷,mamicode.com

时间: 2024-08-05 10:45:21

NHibernate 支持的数据库及配置参数的相关文章

NHibernate支持的数据库 NHibernate连接配置 hibernate.cfg.xml中的配置

使用下列数据库时hibernate.cfg.xml中的配置 Microsoft SQL Server 2005/2000 配置如下: <?xml version="1.0" ?>  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >      <session-factory>          <property name="co

mysql数据库同步配置参数及常见问题

一. 配置参数说明(基本知识): #服务器ID, 每台服务器的ID不能设为相同的数. server-id=1 #启用从库日志,这样可以进行链式复制 log-slave-updates #从库是否只读,0表示可读写,1表示只读 read-only=1 #只复制某个表 replicate-do-table=tablename #只复制某些表(可用匹配符) replicate-wild-do-table=tablename% #只复制某个库 replicate-do-db=dbname #只复制某些库

一个可以把配置参数保存到数据库的函数

一个可以把配置参数保存到数据库的函数 浏览:962 发布日期:2014/05/22 分类:功能实现 关键字: 数据库 参数 不知道TP有没有这个功能,自己做了一个可以把配置参数保存到数据库,Thinkphp 3.2放到/项目目录/Common/Common/function.php里就可以使用了. function CD($key, $value = null){ /** * 公共方法,可以把配置参数保存到数据库 * * 用法: * CD('配置项'); //读取配置项 * CD('配置项',

数据库链接池 durid 的配置参数详解

这里我主要介绍druid 比较重要的参数解释,不做druid的使用介绍,druid虽然功能强大,但是如果对配置参数理解不到位,性能非但不能达到很优,而且会出现很多异常,所以使用druid之前一定要清楚参数设置,要不永远有踩不完的坑. 这里主要介绍那些参数是必要的,对于值的大小,需要根据自己服务器情况,设置. spring.datasource.initialSize=5 // 数据库连接池初始化连接数 spring.datasource.minIdle=5 //数据库连接池中最小连接数,如果长时

Redis数据库安装配置使用

Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合).zset(sorted set --有序集合)和hash(哈希类型).这些数据类型都支持push/pop.add/remove及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的.在此基础

mysql配置参数详解

查看配置参数可以用下面的命令: show variables like '%innodb%';     #查看innodb相关配置参数 show status  like '%innodb%';           #查看innodb相关的运行时参数 show global status like 'open%tables'; # 查看全局的运行时参数,加上global是对当前mysql服务器中运行的所有数据库实例进行统计.不加global则只对当前数据库实例进行统计. my.cnf参数配置 [

ADOdb 支持的数据库包括哪些?

ADOdb 支持的数据库包括 MySQL, PostgreSQL,Interbase,Firebird,Informix,Oracle,MS SQL 7,Foxpro,Access,ADO,Sybase,FrontBase,DB2 和 generic ODBC. ADOdb 的安装安装 ADOdb 是一件极期容易的事,相信聪明的你一定不会感到吃力. 首先, 确定你正在运行的 PHP 是 4.0.4 版或更新版. 如果不是,我强列建议你升级! 从 PHP Everywhere 站点下载 .zip

Mysql一些重要配置参数的学习与整理(二)

原文地址:Mysql一些重要配置参数的学习与整理(二) 上一篇,Mysql一些重要配置参数的学习与整理(一)中,我们了解和学习了mysql配置中的一些重要参数,今天继续进行学习,mysql的配置参数很多,不可能做到面面俱到,这里的总结和整理只是针对于现实生产环境中用到的一些配置参数的学习,接下来,开始本篇的学习.    innodb_flush_log_at_trx_commit = 2        这个变量的官方定义是:Controls the balance between strict

DB2 系统命令与配置参数大全

主要包括4个部分,分别为: DB2 系统命令 DB2 数据库管理器配置参数 DB2 数据库系统配置参数 DB2 管理服务器(DAS)配置参数DB2 系统命令 dasauto - 自动启动 DB2 管理服务器 dascrt - 创建 DB2 管理服务器 dasdrop - 除去 DB2 管理服务器 dasmigr - 迁移 DB2 管理服务器 dasupdt - 更新 DB2 管理服务器 db2_deinstall - 卸载 DB2 产品或功能部件 db2_install - 安装 DB2 产品