Also, several of the objects have aggregate objects that correspond to
relationships in the database. In the process of doing an insert, a row must
be inserted into each table, to enforce referential integrity. However in
an attempt to use transactions at the database level, I have to ensure that
all the objects within a thread use the same OLEDB datasource and session.
I am not sure how to accomplish this. It was my thought that a pointer to
the session could be passed as a constructor to the objects classes, but I
have been unable to make this work. Any suggestions on this matter would be
appreciated.
Thanks in advance.
So each object can create it's own database connection and they all are
going to be as part of one big transaction. Even if they are using
different databases.
So for you it becomes transparent and you do not need to worry about
transactions anymore.
As for Object oriented approach versus "normal approach". From my experience
you should always combine both.
For pure business transaction have a object with corresponding method. Like
Account with Withdraw, Deposit, Balance.
For report operations go directly to database or sometimes it's better to
create separate datawarehouse.
George.
"Matt" <sad...@yahoo.com> wrote in message
news:0W0ia.54742$j8.16...@twister.tampabay.rr.com...
That's a main reason MTS(COM+) is created. To allow your objects participate
in one transaction. Also since OLE DB connections are pooled in MTS
environment you do not incur any performance problem by opening and closing
connection as often as you need.
Example:
Account_Deposit(lAmount)
{
Con.Open(..)
....
Con.Close(...)
Call AnotherObject_AnohterMethod()
SetMyTransactionVote(TxCommit )
}
AnotherObject_AnotherMethod()
{
Con.Open()
...
Con.Close()
SetMyTransactionVote(TxCommit )
}
In this example Deposit did it's job and then called another business
object. Both objects made modification to database. After return from method
Account_Deposit. COM+ checks if all objects voted for transaction to commit
and commits transaction. (Even if those two connections are made to
different databases it will work).
Yes it works the same way as a database transactions. (Actually MTS only
manipulates them). Only MTS sets transaction Level to SERIALIZABLE ( not
sure that you can change it).
If you are using MS SQL then you should not have any problem. I know couple
of years ago people with Oracle were struggling but could make it work. Do
not know about other databases.
George.
"Matt" <sad...@yahoo.com> wrote in message
news:NF7ia.55532$j8.16...@twister.tampabay.rr.com...