ORMConcurrencyException not being thrown

Posts   
 
    
rihadd
User
Posts: 22
Joined: 19-Sep-2007
# Posted on: 26-Mar-2008 19:54:41   

LLBL Pro version = 2.5 final runtime version = v2.0.50727 Using ASP.NET 2.0 Database = MS SQL 2005 Selfservicing

In my webapp I'm storing an Entity in the Viewstate. I'm attempting to implement concurrency control as described in LLBGen documentation. The Entity is retrieved from Viewstate and the Entity.Save() method is called. In a partial class I have overriden the Entity OnInitialized() method to set the ConcurrencyPredicateFactoryToUse. What happens is the Entity does not get commited to the database when the timestamp values don't match, but Entity.Save() returns true and the ORMConcurrencyException does not get thrown. I have tried passing the a filter predicate to the Entity.Save() method directly and get the same exact behavior. I suspect it must have something to do with the way the Entity get deserialized from viewstate, but I'm not sure how to force the ORMConcurrencyException to be thrown or at least have the Save() method retrun false when a concurrency conflict ocurrs. Any ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 27-Mar-2008 04:50:34   

HI rihadd,

The exception should throws. My test reveals that the exception will throws even if the entity is serialized/deserialized. To be sure: 1. Are you sure that the updateRestriction doesn't match? 2. After the deserialization, the ConcurrencyPredicateFactoryToUse isn't null? 3. The entity exist, in other words, an update will be performed (no insert). 4. Important: the entity should be dirty (there are changes to save).

David Elizondo | LLBLGen Support Team
rihadd
User
Posts: 22
Joined: 19-Sep-2007
# Posted on: 27-Mar-2008 15:48:56   

Thanks David, ...when I was testing I was only changing the value of a field in the database table. Did not relealize framework will not attempt to persist the Entity if no changes were made to it and IsDirty is false.