Hi.
I need to work with diferent legacy DBs using one transaction.
I guess the code shuld look like as :

public SomeBussinesMetohd()
{
transaction.begin();

updateDb1.(object); -> this object maps a table in Db 1
updateDb2.(object2); -> this object maps a table in Db 2

if (!error)
{
    transaction.commit(); -> persist data in both DBs
}
else
{
    transaction.rollback();
}

}

As first step. I have my nhibernate configuration file. I've declared
2 session factories in it.

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory name="DB1">
    <property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
    <property name="connection.connection_string">user id=user;data
source=MyServer;persist security info=True;initial
catalog=Test;password=pwd</property>
  </session-factory>

  <session-factory name="DB2">
    <property
name="connection.driver_class">NHibernate.Driver.SqlClientDriver</
property>
    <property name="connection.connection_string">user id=user;data
source=MyServer;persist security info=True;initial
catalog=Test2;password=pwd</property>
  </session-factory>

</hibernate-configuration>

I guess the nhibernate config file is ok.
I am looking for examples about how to declare in code my transaction
and my session factories. Also how to save or update my objects in the
same transaction.
I always use a repository to handle the CRUD operations for an object.
The examples I've seen manage the transaction inside the repository,
so I don't see how to share the transaction between the repositories.

Someone has son example with scenario?

Eddie

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to