Print Page | Close Window

How can a custom AdapterProvider use the same transaction as PersistenceManager

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=585
Printed Date: 12-Mar-2025 at 6:26pm


Topic: How can a custom AdapterProvider use the same transaction as PersistenceManager
Posted By: johneevo
Subject: How can a custom AdapterProvider use the same transaction as PersistenceManager
Date Posted: 06-Dec-2007 at 9:11am
If I create a customer AdapterProvider, can I get my inserts to be included in the same transaction as the other entities being saved that my AdapterProvider is not handling?




Replies:
Posted By: davidklitzke
Date Posted: 06-Dec-2007 at 10:47am
There is no such concept as "the other entities being saved that my AdapterProvider is not handling?"
 
When you use a custom AdapterProvider for, let us say, the Employee table, then that means that all Update, Insert, Modify, and Delete operations for the Employee table are being handled by your Adapter Provider

In most cases the default DataAdapter used internally by DevForce is sufficient for all business objects. The ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.RdbAdapterProvider.html - RdbAdapterProvider creates a provider-specific DataAdapter appropriate to the connection, and builds the ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider.html## - SelectCommand , ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider.html## - UpdateCommand , ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider.html## - InsertCommand and ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider.html## - DeleteCommand needed for the ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence~IdeaBlade.Persistence.EntityTable.html - EntityTable .

A typical reason to implement a custom AdapterProvider is to call your own stored procedures when updating, inserting and deleting data. When implementing this interface, you will construct and initialize a ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider~DataAdapter.html - DataAdapter with the UpdateCommand, InsertCommand and DeleteCommand which the framework will then use for all data modifications to the underlying data source. You will also provide the ms-its:C:\Program%20Files\IdeaBlade%20DevForce\Documentation\IdeaBlade%20DevForce%20Consolidated%20Help.chm::/7/IdeaBlade.Persistence.Server~IdeaBlade.Persistence.Server.IAdapterProvider~Refetch.html - Refetch logic to re-query the data source after modified rows have been saved.



Posted By: johneevo
Date Posted: 06-Dec-2007 at 11:16am
OK,

Let's say that I have created a custom AdapterProvider for the Employee table. Then in an app I update an Employee entity and an Order entity and then call the PersistenceManger's SaveChanges method.

I want to make sure that if the save on the Order entity fails that I can rollback the save to the Employee entity. Just like what would happen if I did not create a custom AdapterProvider for the Employee table and instead just let DevForce take care of all updates.


Posted By: davidklitzke
Date Posted: 06-Dec-2007 at 11:31am

During the transactional save, the PersistenceManager will call the Adapter Provider to modify the Employee Entity and the internal RdbAdapter to modify the Order Entity.  The Employee will be modified first because of its Persistence Order.

If either modification fails, the entire transaction will roll back.


Posted By: johneevo
Date Posted: 06-Dec-2007 at 11:40am
Sweet.

Thanks for your help David.



Print Page | Close Window