The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Need Help - Problem with Transactions and Object Caching

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Sean McCormack

Posts: 504
Nickname: adapdev
Registered: Jan, 2005

Sean McCormack is the Lead .NET Architect for Miller Brewing Co. and founder of Adapdev Technologies
Need Help - Problem with Transactions and Object Caching Posted: Feb 13, 2006 8:35 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Sean McCormack.
Original Post: Need Help - Problem with Transactions and Object Caching
Feed Title: Vini Vidi Vici - Sean McCormack's Blog
Feed URL: http://smccormack.blogs.com/adapdev/SyndicationService.asmx/GetRss
Feed Description: Sean McCormack's Blog, focusing on various aspects of .NET development, open source projects, recommended books and tools
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Sean McCormack
Latest Posts From Vini Vidi Vici - Sean McCormack's Blog

Advertisement
I'm back from the dead. :-)  It's been a hectic couple of weeks...

So, I've encountered an interesting problem and haven't figured out how to get around it.  I was hoping one of you gifted readers could help me!  Here's the problem:

I have a new ORM framework that I'm working on called Elementary, which is very similar to nHibernate and provides some of the advanced features people have asked for in the current Codus DAO Framework (Elementary will be integrated with the Codus generator).

One of the more advanced features that Elementary provides is object-caching.  So, when you request a record from the database, the result is cached.  Next-time you request the same record, the cached object is returned, saving you a full database trip.  It provides for some marked performance improvements.

Here's a typical scenario retrieve and update scenario with caching turned on:
1. A database record is retrieved and turned into an Employee object (Version A).  A copy of the object is put in the cache.
2. The user modifies the record and saves it (Version B).
3. The record is updated in the database and the latest version of the object is put in the cache (Version B).
4. Someone else requests the same record.  Version B is returned from the cache.

All this works fine and dandy until you introduce transactions.  Here's the same scenario, but with a failed transaction:

1. A transaction is opened.
2. A database record is retrieved and turned into an Employee object (Version A).  A copy of the object is put in the cache.
3. The user modifies the record and saves it (Version B).
4. The record is updated in the database and the latest version of the object is put in the cache (Version B).
5. The program rolls back the transaction.  The record in the database, which is Version B, is rolled back to Version A.
5. Someone else requests the same record.  Version B is returned from the cache.

Ahh haa!  A problem.  The database has correctly rolled back the transaction and restored the database record back to the original value.  But, during the update call, the cache was replaced with Version B and is unaware of the rollback.

So, the question is how to you deal with this?  Is there a way to hook into a COM+ transaction and get notified when a rollback occurs...such as an OnAbort event?  Any thoughts?


This weblog is sponsored by Adapdev.Technologies.

Read: Need Help - Problem with Transactions and Object Caching

Topic: VMWare to have a Free Product? Previous Topic   Next Topic Topic: I need more blogs to read

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use