Vous êtes sur la page 1sur 2

NHibernate - Banco de dados Suportados pelo NHibernate

Atualmente os principais banco de dados suportados pelo NHibernate so: Microsoft SQL Server 2008/2005/2000 Oracle Microsoft Access Firebird PostgreSQL DB2 UDB MySQL SQLite Com base nisso segue uma tabela contendo o cdigo para o arquivo de configurao do NHibernate usado para cada um destes bancos de dados. O arquivo de configurao define as informaes do provedor, dialeto, driver e string de conexo do banco de dados usado para persistncia. Lembrando que podemos realizar esta definio no arquivo de configurao da aplicao (app.config ou web.config) ou no arquivo NHibernate.cfg.xml; Obs: A sintaxe usada nas configuraes referem-se a verso 2.1.2 do NHibernate e no devem ser usadas em verses anteriores. <?xml version="1.0" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> SQL Server <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> <?xml version="1.0" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> Microsoft <property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property> Access <property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property> <property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Teste.mdb</property> </session-factory> </hibernate-configuration> <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 Firebird </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> <?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> PostgreSQL <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> <?xml version="1.0" encoding="utf-8" ?> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.0" >

DB2UDB

<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 <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> <?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=localhost;User Id=blah;Password=blah </property> <property name="dialect">NHibernate.Dialect.MySQLDialect</property> </session-factory> </hibernate-configuration> <?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>

MySQL

SQLite

Obs: Atente para o fato que voc dever alterar a string de conexo usada nos exemplos acima.

Recentemente foi lanado o NHibernate 3.1.0 veja detalhes em : http://nhforge.org/Default.aspx


Eu sei apenas NHibernate, mas eu gosto...

Referncias:
http://nhforge.org/Default.aspx VB.NET - Primeiros passos - Conceitos - V NHibernate - Usando o NHibernate 2.1 com o SharpDevelop 3.0 (C#) NHibernate - Usando o ActiveRecord - Macoratti.net VB .NET - Usando o NHibernate - Macoratti.net
Jos Carlos Mac oratti

Vous aimerez peut-être aussi