I have a complex scenario here that I could use some help with. First, it's an 'append-only model' that uses a hilo for new id's.
The primary keys are 'Id' and 'BegEffDate' (datetime). The goal is to still utilize the nhibernate unit of work. What needs to happen though is that if Update is called on an object and it is a type 'IVersionedObject' then instead of being 'updated' it needs to be inserted into the database with the same Id. If it's truly a 'Save' call then it needs to execute the hilo algorithm. I have the 'Save' with hilo working. I created my own TableGenerator and mapped it to my entity. Where I'm struggling is to tell NHibernate that when it has an entity of type 'IVersionedObject' that it should insert a new one vs. updating the existing one. Lastly, what makes it different is the 'BegEffDate' - that date is part of the versioning aspect. It's a manual versioning. ie. If Id is 0, it calls the hilo generator and inserts a record. That is working If Id is not 0, ie. 1 and save is called and it has changes then it should insert a new record. object Id BegEffDate SomeData 1 1/1/2009 12:00:00 123 User updates SomeData to 456 and we call Repository.Update(object) on January 5th, 2009. Since the record is dirty, we know we need to call insert instead of update. Result should be: Id BegEffDate SomeData 1 1/1/2009 123 1 1/5/2009 456 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
