Evict does not cancel the sql statements on the entity

Description

In case of a StaleObjectStateException ( try to update a row with an old value ) if someone tries to handle the exception with a try catch block and on this logic we are evicting the staled entity and then flush the session the update operation is still present.

[TestFixture]
public class StaleObjectTest : PersistenceTestFixture {
[Test]
public void UowStillUsable() {
Foo foo = new Foo("foo1", 12);
using (ISession uow = OpenSession()) {
uow.SaveOrUpdate(foo);
RefreshUow(uow);
Foo loadedFoo = uow.Get<Foo>(foo.Oid);
loadedFoo.Age = 5;
uow.SaveOrUpdate(loadedFoo);
uow.Flush();
}

using (ISession uow = OpenSession()) {
uow.SaveOrUpdate(foo);
try {
uow.Flush();
} catch (StaleObjectStateException e) {
Foo sameFoo = uow.Get<Foo>(e.Identifier);
Assert.IsTrue(ReferenceEquals(foo, sameFoo));
uow.Evict(sameFoo);
Assert.IsFalse(uow.Contains(sameFoo));
}
uow.Flush(); — > this flush will throw again StaleObjectStateException because the update it is still done even if the object has been evicted.
}
}
}

In my opinion if I evict an object from a session, and that object is not linked to any other persisted instance so that through cascade he would be rewritten then the sql statement should be dropped from the queue.

Environment

None

Attachments

1

Activity

Show:
Not an Issue

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created April 4, 2007 at 11:24 AM
Updated April 4, 2007 at 11:58 AM
Resolved April 4, 2007 at 11:33 AM
Who's Looking?