Distributed transaction woes

  • Thread starter Thread starter TJoker .NET
  • Start date Start date
T

TJoker .NET

Hi folks.
I'm having a data visibility issue when using distributed transactions but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one transaction.
Each object has a Save() method that creates a SQLConnection and executes a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves in the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this object the
Controller. In the Controlller my code looks simply like:

<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub

The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')

The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')

The child table has an insert Trigger that validates that [parentKey] is a
valid [key1] in the parent table.

When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.

Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted row ??

Thanks for any feedback!

TJ!
 
Hi TJ,

indeed, the data inserted by the controller should definitely be visible by
the child object(s). Now, the question is -- are the child objects also
ServicedComponent-inherited? do they have at least
TransactionOption.Supported (or .Required)? That's the first thing I'd
check. Other than that you seem to be under the right assumptions.

Guido
 
Guido,
Thanks for the response.
The child objects are not marked with any attribute. They derive stright
from System.Object.
I'm thinking that the child objects will be created inside the same
transaction context as my controller.
But don't bother anymore. Talking to the DBA here, there's a chance that he
coded the Trigger with a bug, so I'm waiting for his answer.

Thanks anyway.

TJ

Guido Domenici said:
Hi TJ,

indeed, the data inserted by the controller should definitely be visible by
the child object(s). Now, the question is -- are the child objects also
ServicedComponent-inherited? do they have at least
TransactionOption.Supported (or .Required)? That's the first thing I'd
check. Other than that you seem to be under the right assumptions.

Guido

TJoker .NET said:
Hi folks.
I'm having a data visibility issue when using distributed transactions but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one transaction.
Each object has a Save() method that creates a SQLConnection and
executes
a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves in the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this object the
Controller. In the Controlller my code looks simply like:

<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub

The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')

The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')

The child table has an insert Trigger that validates that [parentKey] is a
valid [key1] in the parent table.

When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.

Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted row ??

Thanks for any feedback!

TJ!
 
Hi TJoker

Have you signed the child objects with a strong name? Otherwise they won't
participate in the transaction.

/Mats Helander
Pragmatier

TJoker .NET said:
Guido,
Thanks for the response.
The child objects are not marked with any attribute. They derive stright
from System.Object.
I'm thinking that the child objects will be created inside the same
transaction context as my controller.
But don't bother anymore. Talking to the DBA here, there's a chance that he
coded the Trigger with a bug, so I'm waiting for his answer.

Thanks anyway.

TJ

Guido Domenici said:
Hi TJ,

indeed, the data inserted by the controller should definitely be visible by
the child object(s). Now, the question is -- are the child objects also
ServicedComponent-inherited? do they have at least
TransactionOption.Supported (or .Required)? That's the first thing I'd
check. Other than that you seem to be under the right assumptions.

Guido

TJoker .NET said:
Hi folks.
I'm having a data visibility issue when using distributed transactions but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one transaction.
Each object has a Save() method that creates a SQLConnection and
executes
a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves in the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this object the
Controller. In the Controlller my code looks simply like:

<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub

The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')

The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')

The child table has an insert Trigger that validates that [parentKey]
is
a
valid [key1] in the parent table.

When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.

Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted
row
??
Thanks for any feedback!

TJ!
 
What I think you are trying to say is that if don't sign the child
assemblies they will not be found by the controller serviced object, right?
But to answer your question, yes I assigned a strong name to all the
assemblies in my project.

Mats Helander said:
Hi TJoker

Have you signed the child objects with a strong name? Otherwise they won't
participate in the transaction.

/Mats Helander
Pragmatier

TJoker .NET said:
Guido,
Thanks for the response.
The child objects are not marked with any attribute. They derive stright
from System.Object.
I'm thinking that the child objects will be created inside the same
transaction context as my controller.
But don't bother anymore. Talking to the DBA here, there's a chance that he
coded the Trigger with a bug, so I'm waiting for his answer.

Thanks anyway.

TJ

visible
by transactions
but
[parentKey]
is
a
valid [key1] in the parent table.

When I execute the Controller's SaveAll() method the trigger fails saying
that the parentKey (ex: 123) was not found in the parent table.

Is this normal considering that each Save method opens and closes a new
connection, or the trigger should be able to view the newly inserted row
??

Thanks for any feedback!

TJ!
 
Yes, that's what I meant. So that wasn't it, then.

/Mats

TJoker .NET said:
What I think you are trying to say is that if don't sign the child
assemblies they will not be found by the controller serviced object, right?
But to answer your question, yes I assigned a strong name to all the
assemblies in my project.

Mats Helander said:
Hi TJoker

Have you signed the child objects with a strong name? Otherwise they won't
participate in the transaction.

/Mats Helander
Pragmatier

TJoker .NET said:
Guido,
Thanks for the response.
The child objects are not marked with any attribute. They derive stright
from System.Object.
I'm thinking that the child objects will be created inside the same
transaction context as my controller.
But don't bother anymore. Talking to the DBA here, there's a chance
that
he
coded the Trigger with a bug, so I'm waiting for his answer.

Thanks anyway.

TJ

Hi TJ,

indeed, the data inserted by the controller should definitely be visible
by
the child object(s). Now, the question is -- are the child objects also
ServicedComponent-inherited? do they have at least
TransactionOption.Supported (or .Required)? That's the first thing I'd
check. Other than that you seem to be under the right assumptions.

Guido

Hi folks.
I'm having a data visibility issue when using distributed transactions
but
I'm not sure if this is normal or I'm doing something wrong.
I have this object hierachy that is going to be saved as one
transaction.
Each object has a Save() method that creates a SQLConnection and
executes
a
INSERT or UPDATE statement.
I have one object that is responsible for calling all those Saves
in
the
appropriate order. This object is deployed in COM+ (it is a
ServicedComponent with transaction required). Let's call this
object
the
Controller. In the Controlller my code looks simply like:

<AutoComplete(True)> _
Public Sub SaveAll(objParent as ParentType)
objParent.Save()
Dim child as ChildType
For Each child in objParent.Children
child.Save()
Next
End Sub

The Parent.Save executes a SQL statement like:
INSERT INTO parent (key1, col1, col2) VALUES (123, 'abc', 'def')

The Child Save does:
INSERT INTO child (key1, parentKey, col1) VALUES (789, 123, 'xyz')

The child table has an insert Trigger that validates that
[parentKey]
is
a
valid [key1] in the parent table.

When I execute the Controller's SaveAll() method the trigger fails
saying
that the parentKey (ex: 123) was not found in the parent table.

Is this normal considering that each Save method opens and closes
a
new
connection, or the trigger should be able to view the newly
inserted
row
??

Thanks for any feedback!

TJ!
 
Back
Top