I have another problem to solve: have this entity:
when i use this:
in normal way everything is saved to db table. But i want something like that: lets say have this record in db: table 'Contact' columns (& data) ID HistoryID Data1 Data2 1 NULL value1 value2 when update code above is execute i DONT want this: ID HistoryID Data1 Data2 1 NULL value1 new udpate value but want to NOT touch existing row but to create new row with new edited value, table now contains 2 rows after update: ID HistoryID Data1 Data2 1 NULL value1 value2 2 1 value1 new udpate value I want to do this naturally without any special function like (UpdateAndClone) which makes this manually, i want to do this by some special interface attached to entity "Contact" or on some SessionBound derivation class, or other interface which allows me to block updates of existing row and to create new "cloned" row. Is something like this possible within DO4 by natural way or must do it manually? This thread was imported from our support forum. The original discussion may contain more detailed answer. |
In your case I'd do this in more explicit fashion:
So any write operations with such object look like this:
Related issue:
Note that to implement this well, you must attach something like VersionValidator to your sessions (this can be done fully automatically via IModule) - a service, that will be responsible for tracking uncommitted versionized objects and allowing them being writeable + ensuring the identity for mutable versions. Why I recommend this approach:
So I recommend you to use the approach I proposed. Btw, may be it's not a good idea to implement such a "historization" at all: in the worst case only the amount of history will grow up during application lifetime, but not the amount of actual data it deals with. So indexes there will be "flooded" by generally rarely used info. So what's the actual problem you're going to solve? |