Hi,
I have a one-to-many relationship Article-Variables.
First I add some variables to in the articles variables collection, and save them :
public void SaveOrUpdate(T persistentObject, ISession session = null) { try { if (session == null) { session = this.OpenSession(); }
BeginTransaction();
session.SaveOrUpdate(persistentObject);
if (autoCommit) CommitTransaction();
session.Refresh(persistentObject); } catch (Exception ex) { RollbackTransaction(); } finally { if (autoCloseSession) CloseSession(); } }
The changes are successfully propagated to the database - I load the Article and I can see that the Variables collection contains elements.
Then I remove the elements in the Variables collection, and save the changes with the same method. The changed are propagates in the database (i can see the delete queries running, and also i can check that the corresponding records are deleted from the database), But when I load again the Article, it still features the corresponding Variables collection with items in it.
What am I doing wrong ? By calling session.Refresh(persistentObject); I am supposed to refresh the object in the session. Loading the Article reaches everytime the database, as I can see it in the debugger - still the returned records are the outdated ones.
Can you help me ? Thank you.
|