Sunday, February 05, 2012
Support » Support Forum
Register Login
HomeWhat is NDO?- Executive Overview- NDO for DevelopersHow NDO Works- Persistent Classes- Mapping- Queries- Reverse Engineering- Inheritance, Polymorphism- Distributed ApplicationsLicensingSupport- Support Forum- FAQ- Solutions- Downloads- E-Mail Support- Tutorial VideosOnline ShopContact
Welcome to the NDO support forum!
Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender. Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts. The forum software requires that javascript is enabled. Please do not insert licence information or licence keys in forum posts. If you know a good answer to a post of another user, feel free to reply! The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.
Hi all, I have the following code using TimeStamps with the Employee class:
PersistenceManager pm1 = new PersistenceManager(); PersistenceManager pm2 = new PersistenceManager(); pm2.CollisionEvent += new CollisionHandler(MyCollisionEventHandler);
// Loading same object twice as hollow object Employee e1 = pm1.NewQuery(typeof(Employee), "firstName = 'ExistingName'").ExecuteSingle as Employee; Employee e2 = pm2.NewQuery(typeof(Employee), "firstName = 'ExistingName'").ExecuteSingle as Employee;
e1.FirstName = "NewName"; pm1.Save();
e2.FirstName = "NewName2"; pm2.Save(); // Should cause a Collision, but it doesnt occur.
If I change the queries to load the objects as non-hollow objects, the collision event occurs as expected. It this a bug or a feature ?
cheers - a.
Hi A,thanks for your question.
NDO behaves correct. The TimeStamp is loaded at the time, the object is loaded and not at the query time. Because of the loading-on-demand feature the object e1 is loaded at the moment you manipulate it and saved right after that.
e2 is loaded at the moment it is manipulated - that's after saving e1. It loads 'NewName' and overwrites it with 'NewName2'. So, there is no collision happening.
If you changed the order of your statements like that:
e1.FirstName = "NewName"; e2.FirstName = "NewName2"; pm1.Save(); pm2.Save();
you'd get the collision and the collision event is fired.
Best RegardsMirko