[This is preliminary documentation and subject to change.]
Timestamp type for the timestamp properties of the data objects.
For a list of all members of this type, see PmMdaTimestampType Members.
System.Object
NHibernate.Type.AbstractType
NHibernate.Type.NullableType
NHibernate.Type.ImmutableType
NHibernate.Type.ValueTypeType
PmMda.Net.NHibernate.PmMdaTimestampType
This type ensures that the timestamp property and column are updated, if a data object has been modified, even if no column of the corresponding table has changed. Read on for an explanation.
pmMDA implements an optimistic concurrency approach. This approach uses timestamps to version all data objects. The timestamp is a property of the data object (Timestamp). If items are added or removed from an indexed property, the owner of this property must be modified and a new timestamp must be assigned to it.
This is not the normal behaviour, because in the database there is no relation from the owner to its items. Only a foreign key from the items to their owner defines the items of an indexed property. Adding or removing items will therefore not modifiy any column of the owner table.
NHibernate knows how to handle timestamps. But NHibernate assigns the timestamp to the current server time. This would be very bad if there are more than one PersistenceHandler running on different server machines. The approach of pmMDA is slightly different. The timestamp value should be calculated and assigned by the underlying database, so more than one PersistenceHandler are possible. So the NHibernate timestamp implementation conflicts the optimistic concurrency approach of pmMDA and can not be used.
For NHibernate, timestamp properties are handled the same way as primitive properties. The only difference is that timestamps gets a special type (PmMdaTimestampType). This type ensures that the timestamp value, which is assigned to the update and insert statements will be null
. This ensures that the timestamp value of the owner will be updated, even if no other column has been modified.
Example of a timestamp property in NHibernate-repository files:
This type was only tested with MySql. Other databases must be tested.
Namespace: PmMda.Net.NHibernate
Assembly: pmMDA.NET.Common (in pmMDA.NET.Common.dll)
PmMdaTimestampType Members | PmMda.Net.NHibernate Namespace