【问题标题】:NHibernate and Oracle LiteNHibernate 和 Oracle Lite
【发布时间】:2010-02-24 21:21:07
【问题描述】:

有没有人能够成功地将 NHibernate 与 Oracle Lite 一起使用,如果是,你能告诉我我们需要在 hibernate.cfg.xml 中提到什么,我的意思是哪种方言以及我们如何连接到它。谢谢。

【问题讨论】:

    标签: oracle nhibernate


    【解决方案1】:

    您使用的是哪个版本的 NH?似乎这个功能是相当新的,只在实际的 Aplha 中实现:2.1.0.Alpha1。
    改进:
    * [NH-1644] - 具有工作查询参数的 Oracle Lite 驱动程序

    我还没有尝试过,所以我不能说要使用什么连接字符串,但方言应该是“OracleLiteDialect”,正如 Alexandre Payment 所说的 here。 Jira issues 已解决,因此值得一试。

    如果可以连接,请发布连接字符串。

    【讨论】:

      【解决方案2】:

      这是我前段时间做的一个测试项目的 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 数据库:

      • DSN 通常构建为&lt;Oracle lite user name&gt;_&lt;Database name&gt;
      • 用户ID是SYSTEM
      • 密码是 Oracle Lite 用户的实际密码

      比如你的OL用户名是SCOTT,密码是TIGER,数据库名是FOO,Oracle Lite连接字符串是:dsn=SCOTT_FOO;uid=SYSTEM;pwd=TIGER

      希望对你有帮助

      【讨论】:

        【解决方案3】:

        Driver 和 Dialect 类的命名空间分别是 NHibernate.DriverNHibernate.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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2011-03-17
          • 1970-01-01
          • 2020-12-02
          • 2010-10-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多