New Posts New Posts RSS Feed: How can a custom AdapterProvider use the same transaction as PersistenceManager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

How can a custom AdapterProvider use the same transaction as PersistenceManager

 Post Reply Post Reply
Author
johneevo View Drop Down
Newbie
Newbie


Joined: 03-Dec-2007
Location: United States
Posts: 8
Post Options Post Options   Quote johneevo Quote  Post ReplyReply Direct Link To This Post Topic: How can a custom AdapterProvider use the same transaction as PersistenceManager
    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?

Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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 RdbAdapterProvider creates a provider-specific DataAdapter appropriate to the connection, and builds the SelectCommand, UpdateCommand, InsertCommand and DeleteCommand needed for the 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 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 Refetch logic to re-query the data source after modified rows have been saved.

Back to Top
johneevo View Drop Down
Newbie
Newbie


Joined: 03-Dec-2007
Location: United States
Posts: 8
Post Options Post Options   Quote johneevo Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
johneevo View Drop Down
Newbie
Newbie


Joined: 03-Dec-2007
Location: United States
Posts: 8
Post Options Post Options   Quote johneevo Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2007 at 11:40am
Sweet.

Thanks for your help David.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down