Multiple Databases with NHibernate

I have two databases. One of Oracle 10g. Another one from Mysql. I configured my web application using Nhibernate for Oracle, and now I need to use the MySQL database. So, how can I configure hibernate.cfg.xml so that I can use both databases in the same application?

My current hibernate.cfg.xml:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
    <property name="connection.connection_string">Data Source=xe;Persist Security Info=True;User ID=hr;Password=hr;Unicode=True</property>
    <property name="show_sql">false</property>
    <property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>
    <!-- mapping files -->
    <mapping assembly="DataTransfer" />
  </session-factory>
</hibernate-configuration> 
+3
source share
2 answers

You can check out the "Burrow" add-on for nhibernate

http://nhforge.org/wikis/burrow/introduction.aspx

Multiple databases support. multiple databases becomes easy, you don't need a SessionFactoryPath, you simply give Burrow an entity type, and Burrow will find the right ISession for you. If you are using GenericDAO, the multiple DB support can be very transparent - your code does not need to know there are multiple databases.

It seems you can also use unhaddins, did not use it, and I did not find the documentation. http://code.google.com/p/unhaddins/

, , , .

http://www.codeproject.com/KB/aspnet/NHibernateMultipleDBs.aspx

+2

. , hibernate session- factory, NHibernate.Cfg.Configuration.Configure, sessionFactoryName.

NHibernate hibernate.cfg.xml,

0

Source: https://habr.com/ru/post/1741482/


All Articles