【发布时间】:2010-02-24 21:21:07
【问题描述】:
有没有人能够成功地将 NHibernate 与 Oracle Lite 一起使用,如果是,你能告诉我我们需要在 hibernate.cfg.xml 中提到什么,我的意思是哪种方言以及我们如何连接到它。谢谢。
【问题讨论】:
标签: oracle nhibernate
有没有人能够成功地将 NHibernate 与 Oracle Lite 一起使用,如果是,你能告诉我我们需要在 hibernate.cfg.xml 中提到什么,我的意思是哪种方言以及我们如何连接到它。谢谢。
【问题讨论】:
标签: oracle nhibernate
这是我前段时间做的一个测试项目的 app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.OracleLiteDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OdbcDriver</property>
<property name="connection.connection_string">dsn=TheDSN;uid=TheUserId;pwd=ThePassword</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
</configuration>
注意:连接到本地 Oracle Lite 数据库:
<Oracle lite user name>_<Database name>
SYSTEM
比如你的OL用户名是SCOTT,密码是TIGER,数据库名是FOO,Oracle Lite连接字符串是:dsn=SCOTT_FOO;uid=SYSTEM;pwd=TIGER
希望对你有帮助
【讨论】:
Driver 和 Dialect 类的命名空间分别是 NHibernate.Driver 和 NHibernate.Dialect。您可以使用 Intellisense 或 Reflector 来准确查看可用的内容。
Oracle Lite 的会话工厂配置:
<property name="connection.connection_string">...</property>
<property name="connection.driver_class">NHibernate.Driver.OracleLiteDataClientDriver</property>
<property name="dialect">NHibernate.Dialect.OracleLiteDialect</property>
Oracle 连接字符串描述为here。
【讨论】: